[systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix

Christian Seiler christian at iwakd.de
Sat May 30 04:13:23 PDT 2015

On 05/30/2015 12:42 PM, Daniel Mack wrote:
> On 05/30/2015 12:31 PM, Christian Seiler wrote:
>> Speaking of: using 'echo' for shell scripting is problematic, because
>> while bash, busybox's sh, mksh, pdksh and zsh don't interpret escape
>> sequences (\n, \0oo, ...) by default when using echo and invoked as
>> /bin/sh, dash and ash do. (Note that e.g. dash ist default on Debian,
>> so it's not like this is something theoretical.) Also, when invoked as
>> their proper name (not as /bin/sh), only bash and busybox's shell do
>> not interpret escape sequences by default with echo. (In short: it's a
>> mess.)
> It's a mess indeed. Now we only need a POSIX compliant way to strip
> _all_ trailing dashes from a string, then we can get rid of that one
> occurrence of 'sed' in configure.ac :)

Define once:

# (local variables in functions are a bashism, don't use them, but
# name global variable in such a way that it won't clash with
# anything else)
        while [[ "${_strip_trailing_slashes_value}" != "${_strip_trailing_slashes_value%/}" ]] ; do
        printf '%s\n' "${_strip_trailing_slashes_value}"


VAR=$(strip_trailing_slashes "$VAR")

(Or, alternatively, repeat the loop each time, you're using M4
anyway, so you could AC_DEFUN the whole thing.)

It's up to you to decide what you find more appealing.


More information about the systemd-devel mailing list