Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: cd with empty argument does not conform to POSIX.1-2024 (Was: inherit OLDPWD from environment variable)



On Tue, Jul 23, 2024, at 11:47 AM, Mark J. Reed wrote:
>> The current behavior is to do nothing and exit with a zero status.
>
> For comparison purposes, note that this is also the current behavior of 
> bash, even in POSIX mode.

This will be fixed in the next release; the development version [*]
already errors out:

	% ./bash -c 'echo "$BASH_VERSION"; cd ""'
	5.3.0(6)-alpha
	./bash: line 1: cd: null directory

[*]: https://git.savannah.gnu.org/cgit/bash.git/tree/builtins/cd.def?h=devel&id=6c703092759ace29263ea96374e18412c59acc7f#n333


> Also dash.

Presumably a future release will fix this, given dash's explicit
goal of POSIX conformance.


> Whereas ksh does report an error  ("bad directory") and exit
> with status 1.

This bolsters the argument for, at a minimum, updating ksh/sh
emulation via POSIX_CD, as does the fact that the Solaris 10
Bourne shell fails too.


-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author