Program flow corruption involving 'command .' and an invalid expansion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Attempting to eval an invalid expansion in a subshell (e.g. by doing a feature test for bash-style ${x/y/z} expansions) in a script sourced with 'command .' causes program flow corruption in dash, current git as well as 0.5.10.2.

Test scripts, one sourcing the other with 'command .':

# test.sh
echo one
command . ./test2.sh
echo four

# test2.sh
echo two
(eval 'y=${x/y/z}')
echo three

Initial output:

$ dash test.sh
one
two
test.sh: 1: eval: Bad substitution
four

Then dash goes in some kind of half-interactive mode. It accepts commands like 'ls' but does not display a prompt. The 'set -i' command activates the prompt.

When leaving that phantom interactive shell with 'exit' or ^D, the final output is:

three
four

Note that the 'echo four' in test.sh is executed twice.

Also, gwsh does not exhibit these symptoms.

- Martijn



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux