dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] Interactive (d)ash exits on assigning to readonly from 'command eval'
@ 2016-10-27 21:40 Martijn Dekker
  2016-10-28 13:55 ` Denys Vlasenko
  0 siblings, 1 reply; 4+ messages in thread
From: Martijn Dekker @ 2016-10-27 21:40 UTC (permalink / raw)
  To: dash, busybox

This bug is on both dash and busybox ash.

The "command" builtin is supposed to stop special builtins (such as
"eval") from exiting the shell on error. So doing something like

   isreadonly() {
      ! command eval "$1=" 2>/dev/null

ought to be a way to test if a variable is read-only without the
performance hit of forking a subshell.

Using this function works fine in scripts, but it immediately makes an
interactive dash or ash exit. The same happens if you try a similar
command manually.

bash$ dash
$ readonly bla=123
$ command eval bla=457
dash: 1: eval: bla: is read only

After the "is read only" error, dash prints a prompt, but does not wait
for input and exits instead. Busybox ash does not even print the prompt
before exiting.

The funny part is that the interactive shell does not exit if you leave
out the 'command'. The very thing that is supposed to stop a
non-interactive shell from exiting makes an interactive shell exit.


- M.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-30 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 21:40 [BUG] Interactive (d)ash exits on assigning to readonly from 'command eval' Martijn Dekker
2016-10-28 13:55 ` Denys Vlasenko
2016-10-29 18:22   ` Harald van Dijk
2016-10-30 17:32     ` Denys Vlasenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).