Skip to content

Improve xdt-autogen

At first, I modified this script locally to be able to build when paths contain whitespaces.
Then, I tried to make these changes cleaner (keeping a strictly posix script, which seems to be a constraint here), and finally, this led me to do a fairly complete review of the script:

  • quoting;
  • backticks -> $()
  • do not use subshells when unneeded;
  • tr | sed or sed | tr -> sed;
  • some defensive programming techniques (some from shellcheck);
  • readability.

So I decided to share this, even if xdt-autogen.in appears in .gitignore (actually, it is still tracked: a forgotten git rm --cached scripts/xdt-autogen.in?)

Apart the case of paths containing whitespaces, the only modification that should change the behavior of the script is the following:
tr '\\n\\t\\\\' ' ' changed to sed 's|\\[\\nt]| |g'
This is not the same, and I think the first code is wrong, due to a misunderstanding of how tr works (hope it is not a misunderstanding on my part! 😂).

Regarding whitespaces (and more generally special characters in filenames), I changed the filename separator from ' ' to '\1' in lookup_configure_ac_*(), and I used a permutation of the value of the IFS special variable around for loops.
It is almost sufficient, except for running $XDT_PROG_ACLOCAL, where one has to define two new variables ACLOCAL_DIR_? and use conditional parameter expansion to properly build the command line.

Merge request reports