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

Mike Frysinger vapier at gentoo.org
Fri Mar 15 22:32:37 UTC 2013


On Friday 15 March 2013 16:54:24 Joshua Judson Rosen wrote:
> 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.

aborting is correct behavior:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#dot
	"If no readable file is found, a non-interactive shell shall abort"

this is why bash (when run in posix mode) aborts.

that said, adding the behavior behind ENABLE_ASH_BASH_COMPAT should be fine
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20130315/1b3f527c/attachment.asc>


More information about the busybox mailing list