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

Daniel Mack daniel at zonque.org
Sat May 30 03:42:57 PDT 2015


On 05/30/2015 12:31 PM, Christian Seiler wrote:
> On 05/30/2015 10:28 AM, Daniel Mack wrote:
>> On 05/30/2015 08:50 AM, Mike Gilbert wrote:
>>> On Fri, May 29, 2015 at 8:05 PM, Daniel Mack <daniel at zonque.org> wrote:
>>>> Make sure the variable set via --with-rootprefix= does not contain a
>>>> trailing slash, so man pages can use entities like "&rootprefix;/lib"
>>>> without ending up having double slashes.
>>>> ---
>>>>  configure.ac | 3 ++-
>>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/configure.ac b/configure.ac
>>>> index 92654a6..55b73de 100644
>>>> --- a/configure.ac
>>>> +++ b/configure.ac
>>>> @@ -1396,7 +1396,8 @@ AC_ARG_WITH([zshcompletiondir],
>>>>
>>>>  AC_ARG_WITH([rootprefix],
>>>>          AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]),
>>>> -        [], [with_rootprefix=${ac_default_prefix}])
>>>> +        [with_rootprefix=`echo ${withval} | sed -e s,/*$,,`],
>>>> +        [with_rootprefix=${ac_default_prefix}])
>>>
>>> Why do you pipe it through sed when a simple shell parameter expansion would do?
>>>
>>> with_rootprefix=${withval%/}
>>
>> Isn't that's a bash'ism which we try to avoid at other places? FWIW, we
>> use sed to strip off trailing dashes from $host for EFI_ARCH. Also, that
>> one only replaces one trailing slash, not all of them.
> 
> No, it's not a bashism, it's indeed POSIX. See:
> http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
> 
> For example:
> 
> V="aXbXc"
> printf '%s\n' "${V#*X}"
> printf '%s\n' "${V##*X}"
> printf '%s\n' "${V%X*}"
> printf '%s\n' "${V%%X*}"
> 
> When using either one of bash, dash, ash, busybox's shell, mksh, pdksh
> and zsh as /bin/sh, it all produces the same output:

Interesting. I always looked up those sequences in the 'Advanced
Bash-Scripting Guide', so I considered them special to bash. Thanks for
the explanation.

> 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 :)


Thanks,
Daniel



More information about the systemd-devel mailing list