Problem with ash redirection changing behaviour
rpurdie at rpsys.net
Wed Jun 2 09:56:43 UTC 2010
I have an issue having recently upgraded busybox. The change that is
causing me problems is:
which is sanity checking file descriptors before allowing redirection.
A script that triggers the problem is:
exec 9>&0 </etc/fstab
while read fs mnt type opts dump pass junk
exec 0>&9 9>&-
The idea being to save stdin, read from a file and then restore stdin
without forking. This used to work but now when run as ". script" from
ash this results in:
line 1: 0: Bad file descriptor
which is in turn due to is_hidden_fd() returning 1 since stdin was being
read as the source for commands.
I can see what its getting at as stdin was where the main shell was
accepting data from. bash doesn't error with this.
Is this error the expected result or a bug in busybox?
I can see some argument for saving copies of fd's when using
pushfile()/popfile() but I thought I'd ask the question.
More information about the busybox