autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] docs: mention cd limitation


From: Paolo Bonzini
Subject: Re: [PATCH 1/2] docs: mention cd limitation
Date: Sat, 31 Jul 2010 11:24:50 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Thunderbird/3.0.5

On 07/30/2010 12:24 AM, Eric Blake wrote:
+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.

bash's behavior is to do nothing.  We may suggest

  cd "${var:-.}"

which is the closest thing to a sensible behavior (better than changing to HOME...).

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]