From: Eric Blake Date: Thu, 29 Jul 2010 22:10:26 +0000 (-0600) Subject: docs: mention cd limitation X-Git-Tag: v2.68~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e7b9effeafd5c1263c66784409903dbdf526d93;p=thirdparty%2Fautoconf.git docs: mention cd limitation * doc/autoconf.texi (Limitations of Builtins) : Document issues with empty argument. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 662a6e1e8..278a56564 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-07-29 Eric Blake + + docs: mention cd limitation + * doc/autoconf.texi (Limitations of Builtins) : Document + issues with empty argument. + 2010-07-29 Ralf Wildenhues Add missing index entries to manual. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index fac50b297..493b9dcc8 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -16543,6 +16543,16 @@ Also, Autoconf-generated scripts check for this problem when computing variables like @code{ac_top_srcdir} (@pxref{Configuration Actions}), so it is safe to @command{cd} to these variables. +Posix states that behavior is undefined if @command{cd} is given an +explicit empty argument. Some shells do nothing, some change to the +first entry in @env{CDPATH}, some change to @env{HOME}, and some exit +the shell rather than returning an error. Unfortunately, this means +that if @samp{$var} is empty, then @samp{cd "$var"} is less predictable +than @samp{cd $var} (at least the latter is well-behaved in all shells +at changing to @env{HOME}, although this is probably not what you wanted +in a script). You should check that a directory name was supplied +before trying to change locations. + See @xref{Special Shell Variables}, for portability problems involving @command{cd} and the @env{CDPATH} environment variable. Also please see the discussion of the @command{pwd} command.