Date: Mon, 30 Aug 1999 22:57:50 -0500 From: Jon Hamilton <hamilton@pobox.com> To: Greg Lehey <grog@lemis.com> Cc: Brian Somers <brian@Awfulhak.org>, Roelof Osinga <roelof@nisser.com>, Patrick Seal <patseal@hyperhost.net>, freebsd-questions@FreeBSD.ORG Subject: Re: Bash: space in cd arg bug? Message-ID: <19990831035750.43D82A0@woodstock.monkey.net> In-Reply-To: Your message of "Tue, 31 Aug 1999 11:52:27 %2B0930." <19990831115226.X13904@freebie.lemis.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <19990831115226.X13904@freebie.lemis.com>, Greg Lehey wrote: } On Tuesday, 31 August 1999 at 0:02:20 +0100, Brian Somers wrote: } > [.....] } >>> You missed the } >>> } >>> zsh -> echo $FOO } >>> /C:/Program Files } >>> zsh -> mkdir $FOO } >>> } >>> Which makes two directories. Why should ``cd'' behave differently } >>> from an external command - just because it's a builtin ? } >> } >> It shouldn't. } >> } >>> IMHO, zsh is wrong. } >> } >> Agreed. And bash does exactly the same thing in this case. } > } > Someone said that ``cd $FOO'' was being interpreted as } > ``cd "Program Files"'' (two words) rather than as } > ``cd Program Files'' (three words). The correct interpretation } > (which is the same as bash's interpretation) is as three words. } } Why is this correct? How do I store a directory name which contains } in a variable and then change to it? It's not correct just to cd $* } instead of cd $1, because there could be multiple contiguous spaces in } the directory name. [501] hamilton@woodstock /tmp$ FOO=my\ directory\ name\ with\ spaces [502] hamilton@woodstock /tmp$ echo $FOO my directory name with spaces [503] hamilton@woodstock /tmp$ cd "$FOO" [504] hamilton@woodstock my\ directory\ name\ with\ spaces$ pwd /tmp/my directory name with spaces I think you are trying to be pedantic, but I'm not sure that your wishes are consistent with the way the shell operates, and with historic operation of sh. What other circumstance can you think of in which an unquoted parameter expansion containing spaces results in words not being broken at each whitespace sequence? -- Jon Hamilton hamilton@pobox.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990831035750.43D82A0>