harden alias against foo; bar

If the first word of the alias body ends with a semicolon we need to
strip that character, and otherwise escape the extracted command, to
ensure the subsequent function definition is valid.

Fixes #3860
This commit is contained in:
Kurtis Rader
2017-02-20 20:23:55 -08:00
parent 992e1d0059
commit 9dd0c47d0b
4 changed files with 19 additions and 6 deletions

0
tests/alias.err Normal file
View File

7
tests/alias.in Normal file
View File

@@ -0,0 +1,7 @@
# Avoid regressions of issue #3860 wherein the first word of the alias ends
# with a semicolon.
function foo
echo ran foo
end
alias my_alias "foo; and echo foo ran"
my_alias

2
tests/alias.out Normal file
View File

@@ -0,0 +1,2 @@
ran foo
foo ran