At Friday 30 July 2010, Eric Blake wrote: > * doc/autoconf.texi (Limitations of Builtins) <cd>: Document > issues with empty argument. > > Signed-off-by: Eric Blake <[email protected]> > --- > > Pushing both of these, to address recent issues brought up on the > list. > > ChangeLog | 6 ++++++ > doc/autoconf.texi | 10 ++++++++++ > 2 files changed, 16 insertions(+), 0 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 662a6e1..278a565 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,9 @@ > +2010-07-29 Eric Blake <[email protected]> > + > + docs: mention cd limitation > + * doc/autoconf.texi (Limitations of Builtins) <cd>: Document > + issues with empty argument. > + > 2010-07-29 Ralf Wildenhues <[email protected]> > > Add missing index entries to manual. > diff --git a/doc/autoconf.texi b/doc/autoconf.texi > index fac50b2..493b9dc 100644 > --- a/doc/autoconf.texi > +++ b/doc/autoconf.texi > @@ -16543,6 +16543,16 @@ Limitations of Builtins > 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. > + FWIW, I'd never thought such a schizophrenic behaviour was possible, so I find your documention patch very useful.
Regards, Stefano
