]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
docs: mention cd limitation
authorEric Blake <eblake@redhat.com>
Thu, 29 Jul 2010 22:10:26 +0000 (16:10 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 29 Jul 2010 22:21:20 +0000 (16:21 -0600)
* doc/autoconf.texi (Limitations of Builtins) <cd>: Document
issues with empty argument.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/autoconf.texi

index 662a6e1e8835d9b53785c84844fa043d4ce14353..278a56564913c4ecbfe725adfdd377956322ded8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-07-29  Eric Blake  <eblake@redhat.com>
+
+       docs: mention cd limitation
+       * doc/autoconf.texi (Limitations of Builtins) <cd>: Document
+       issues with empty argument.
+
 2010-07-29  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Add missing index entries to manual.
index fac50b2976754dc8799b21fd061e72dddf3b5a7a..493b9dcc85f2ef95c0d4393d70eab56680d8c854 100644 (file)
@@ -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.