You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a shell function in aliases the parameters are not quoted correctly.
Here is a simple alias for testing (~/.aws/cli/alias):
[toplevel]
test-quotes =
!f() {
for i in "$@"; do
echo "$i"
done
}; f
Testing the alias with aws test-quotes foo bar "foo bar":
Desired output:
foo
bar
foo bar
Actual output:
foo
bar
foo
bar
When debugging the ExternalAliasCommand's __call__ method the command_components variable contains ['f() {\nfor i in "$@"; do\necho "$i"\ndone\n}; f', 'foo', 'bar', 'foo bar'] so the quoted parameter with a space is parsed correctly on input.
However when making the actual function call the parameter is not quoted correctly: Using external alias 'test-quotes' with value: '!f() {\nfor i in "$@"; do\necho "$i"\ndone\n}; f' to run: 'f() {\nfor i in "$@"; do\necho "$i"\ndone\n}; f foo bar foo bar'
One fix could be to use quote function from https://pypi.python.org/pypi/shellescape (backport of Python shlex.quote for Python versions 2.x & < 3.3) for args to get arguments escaped correctly but this creates a new dependency. (something like command_components.extend(map(quote, args)))
Version info: CLI version: aws-cli/1.11.101 Python/2.7.13 Darwin/16.5.0 botocore/1.5.64
The text was updated successfully, but these errors were encountered:
Hi,
When using a shell function in aliases the parameters are not quoted correctly.
Here is a simple alias for testing (~/.aws/cli/alias):
Testing the alias with
aws test-quotes foo bar "foo bar"
:Desired output:
Actual output:
When debugging the
ExternalAliasCommand
's__call__
method thecommand_components
variable contains['f() {\nfor i in "$@"; do\necho "$i"\ndone\n}; f', 'foo', 'bar', 'foo bar']
so the quoted parameter with a space is parsed correctly on input.However when making the actual function call the parameter is not quoted correctly:
Using external alias 'test-quotes' with value: '!f() {\nfor i in "$@"; do\necho "$i"\ndone\n}; f' to run: 'f() {\nfor i in "$@"; do\necho "$i"\ndone\n}; f foo bar foo bar'
One fix could be to use
quote
function from https://pypi.python.org/pypi/shellescape (backport of Pythonshlex.quote
for Python versions 2.x & < 3.3) forargs
to get arguments escaped correctly but this creates a new dependency. (something likecommand_components.extend(map(quote, args))
)Version info:
CLI version: aws-cli/1.11.101 Python/2.7.13 Darwin/16.5.0 botocore/1.5.64
The text was updated successfully, but these errors were encountered: