| On Tue, Nov 07, 2000 at 06:09:45PM +0100, Akim Demaille wrote:
| : absolute="`cd "$relative" && pwd`"
| : 
| : is not portable, and nor is
| : 
| : absolute="`cd \"$relative\" && pwd`"
| 
| That the first line is not portable comes as no surprise.
| That the second one isn't - I find obscene...

Yep, sorry :(

autoconf.texi
>    Contrary to a persistent urban legend, the Bourne shell does not
> systematically split variables and backquoted expressions, in
> particular, the following code:
> 
>      case "$given_srcdir" in
>      .)  top_srcdir="`echo "$dots" | sed 's,/$,,'`"
>      *)  top_srcdir="$dots$given_srcdir" ;;
>      esac
> 
> is more readable with the right-hand side of the assignments, and the
> argument of `case' left without quotes:
> 
>      case $given_srcdir in
>      .)  top_srcdir=`echo "$dots" | sed 's,/$,,'`
>      *)  top_srcdir=$dots$given_srcdir ;;
>      esac
> 
> and in fact it is even _more_ portable: in the first case of the first
> attempt, the computation of `top_srcdir' is not portable, since not all
> the shells understand properly `"`... "foo"... `"'.  Worse yet, not all
> the shells understand `"`... \"foo\"... `"' the same way: there is just
> no portable way to use double-quoted strings inside double-quoted
> backquoted expressions (Pfew!).


| : You don't have to quote rhs of assignments, nor the case argument
| : 
| : case `echo there are spaces in there` in
| :   "there are"*there ) echo OK;;
| :   *) echo 'Niah???';;
| : esac
| 
| You probably mean that you don't have to quote rhs and the case
| argument as long as they are expansions from some construct that
| doesn't need quoting.  You can't do the following:
| 
| absolute=C:\\Windows\\Program Files
| 
| case there are spaces in there in

Yes, of course.

Reply via email to