Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
$(<nofile) doesn't set $? to non-zero
- X-seq: zsh-workers 42459
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: $(<nofile) doesn't set $? to non-zero
- Date: Wed, 14 Mar 2018 10:32:54 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=vQF80epV0nAi2bcCqSOAw9RM56TheQLR4ZIkeUemTTE=; b=bOgNFrYoy9Zb9iPFaRBweoFUHcfa1qaifMV/Hn6b7979YQbrFZsgrpGV+zKvQ2H0DV 2xAI85bTwUWbUyAAYK2f0edP6hwFnf/yNsaYBxVG3a7TyiwXMCR6I9BsXu1epu3ZND7V +rRjxaTzodqu8sOjpPJVLO/5meDnetUwWH9fOIySbuYefMhO08xUI5/CTAD2+2CFD+tf H/dO6gs0mv18DCwAjANRnV79FvqhsecrrJom/O9d4LIfZoPzing+2qfBBt8l2PBhtbdJ DxfOPbfertObi0i+58GGieaUR08uRNSWCSoCv7FMrMK8RVzIu83RjxQcY3vAae9xQNeN GepA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
$ 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