Date: Mon, 16 Feb 2026 17:07:57 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 293212] bin/sh does not set exitstatus for heredoc expansion errors Message-ID: <bug-293212-227-OHmQ2sZjYN@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-293212-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293212 Jilles Tjoelker <jilles@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|New |Open --- Comment #1 from Jilles Tjoelker <jilles@FreeBSD.org> --- I originally implemented it like this for compatibility with the original implementation that expanded the here-document in a child process. That change (4dc6bdd3e7e670c195cd66b9319b4059f572cdfc in git) was intended to improve performance without changing behaviour much. However, I agree the behaviour is not ideal. Most shells appear to treat this expansion error in a here-document like a redirection error, so it causes the shell to skip executing the command and return a non-zero exit status, and if the command is a special builtin the shell also aborts (i.e. even if `set -e` is not in effect). There may be a difference in the handling of expansion errors in a here-document and in a redirection pathname. The latter causes the shell to abort in our sh, dash and mksh. Shells differ in whether side effects from here-document expansion (such as ${x:=1} and $((x+=1))) persist. In our sh, bash and zsh, they do not and in most others (dash, mksh, ksh93) they do. We could change this too if it is more expected. -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-293212-227-OHmQ2sZjYN>
