Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autopoint doesn't handle unquoted aux dirs correctly #61

Open
awilfox opened this issue Jun 15, 2023 · 4 comments
Open

autopoint doesn't handle unquoted aux dirs correctly #61

awilfox opened this issue Jun 15, 2023 · 4 comments

Comments

@awilfox
Copy link
Contributor

awilfox commented Jun 15, 2023

Elizafox/tre-regex-sys#1 has led me to a curious thing:

AC_CONFIG_AUX_DIR(utils)

will break gettext-tiny's autopoint:

awilcox on gwyn ~/Code/contrib/tre-regex-sys/tre % find . -name config.rpath
./AC_CONFIG_AUX_DIR(utils)/config.rpath

because it doesn't have the bracket quotes that autopoint is expecting:

  if [ "${line##*AC_CONFIG_AUX_DIR}" != "$line" ]; then
    dirprefix="${line##*([}"
    dirprefix="${dirprefix%%])*}"
    mkdir -p "${dirprefix}"
  fi

Trying to see if we can find an easy fix.

@xhebox
Copy link
Collaborator

xhebox commented Jun 15, 2023

If we can do something like dirname $line? But that depends on coreutils.

@Elizafox
Copy link

Elizafox commented Jun 15, 2023

If we can do something like dirname $line? But that depends on coreutils.

dirname is POSIX, but:

elizabeth@ember:~ % dirname "AC_CONFIG_AUX_DIR(utils)"
.

That won't work.

The best thing to do imo is use sed:

dirprefix="$(echo "$line" | sed -E 's#\[|\]##g;s#.*\((.*)\)#\1#')"

Example:

elizabeth@ember:~ % echo "AC_CONFIG_AUX_DIR([utils])" | sed -E 's#\[|\]##g;s#.*\((.*)\)#\1#'
utils

The reason for the two regexes is that for some reason I cannot fathom, [^\]\)] does not work in a capturing group, so they have to be stripped first. You could do:

dirprefix="$(echo "$line" | sed -E 's#\[|\]##g)"
dirprefix="${dirprefix##*(}"
dirprefix="${dirprefix%%)*}"

Or some such, but I see little to no benefit.

@rofl0r
Copy link
Member

rofl0r commented Jun 16, 2023

or pipe through awk, which is probably way less cryptic to the reader. anyone working on a patch ?

@trushworth
Copy link

awilfox's suggested one-line fix:

The fix is pretty simple: replace AC_CONFIG_AUX_DIR(utils) with AC_CONFIG_AUX_DIR([utils]) in configure.ac.

has been commited to laurikari/tre if you want to use the latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants