Created
February 23, 2018 16:01
-
-
Save minrk/527a11b2442d7b3188ed7880cbda6d7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# show-args is a Python script that prints sys.argv[1:] | |
echo '$@ =' "$@" | |
echo 'no quotes: $@' | |
show-args $@ | |
echo 'quotes: "$@"' | |
show-args "$@" | |
AT="$@" | |
echo 'quotes: "$AT" where AT="$@"' | |
show-args "$AT" | |
echo 'no quotes: $AT' | |
show-args $AT | |
echo "HOW DOES THAT WORK" |
Ah… i just realised I needed to add args after the invocation:
edit:
$ ./test.sh has space arg 2
and I needed to group the args to get the effect you're seeing:
$ ./test.sh "has space" "arg 2"
I got:
./test.sh "has space" "arg 2"
$@ = has space arg 2
no quotes: $@
['has', 'space', 'arg', '2']
quotes: "$@"
['has space', 'arg 2']
quotes: "$AT" where AT="$@"
['has space arg 2']
no quotes: $AT
['has', 'space', 'arg', '2']
HOW DOES THAT WORK
So it looks like I can reproduce… this is so weird.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could you add show-args as a file to this gist? I wanted to reproduce this exactly and I'm finding it tricky to execute show-args as a script without creating a full package to declare it as an console_script entrypoint… unless that's actually what you did to get that script to work without explicitly in.
Is it more than:
Also… even modifying it to :
I'm still only getting
So i'm guessing there's a bit more setup than I'm realising…