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

$(<nofile) doesn't set $? to non-zero



$ zsh -c 'ar=$(<file); echo "$?"'
zsh:1: no such file or directory: file
0

That's different from other shells (ksh93, bash, mksh) that
return 1, and is also inconsistent with the cases where $(<) is
not recognised as that operator and runs the NULLCMD instead:

$ zsh -c 'var=$(<file >/dev/null); echo "$?"'
zsh:1: no such file or directory: file
1

Note that all shells are silent and return 0 for var=$(</etc)
var=$(</dev/mem) or any file that can be opened but not read
successfully, which IMO is not ideal.

-- 
Stephane



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