ash: "source <nonexistent file>" makes ash exit?

Joshua Judson Rosen jrosen at harvestai.com
Fri Mar 15 20:54:24 UTC 2013


I just noticed that trying to source a nonexistent file from a script running
(non-interactively) through ash causes the shell to exit.

Debian's "dash" shell doesn't do this, and versions of bash before 4.2
apparently don't do this even when invoked with "--posix" (it looks like bash's
posix mode was always *supposed to* exit when trying to source non-existent
files, but was perhaps broken; bash's *default mode* doesn't exit when an
attempt is to source a nonexistent file, though).

Looking at the code in busybox, it looks like there's an obvious patch that I
can make (cf. attached) in order to change this behaviour; does this change
make sense upstream? If I do it, should I predicate it on ENABLE_ASH_COMPAT,
or should I just do it unconditionally (I notice that busybox's find_dot_file()
always searches in the current directory, which looks like a bashism)?

Or should I just not do it, and make my shell scripts smarter?
It's not entirely clear, looking at dotcmd(), whether the INPUT_NOFILE_OK
flag/logic is intentionally omitted from the setinputfile() call, or whether
it's an oversight.

-- 
"Don't be afraid to ask (λf.((λx.xx) (λr.f(rr))))."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ash-dotcmd-nofile-ok.patch
Type: text/x-patch
Size: 652 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20130315/e3157877/attachment.bin>


More information about the busybox mailing list