$@ drops quotation marks #3385
Replies: 1 comment
-
I am fairly certain that the quotes get interpreted as "this is one argument" (which in this case is totally unnecessary because the command-line argument does not contain any whitespace that would cause it to be mistaken for multiple arguments. That's what $ git -c alias.auermich="!f() { for arg; do echo `$arg; done; }; f" auermich 1 2 3 "4 5"
1
2
3
4 5 It would get quite tricky if you wanted to preserve the double-quotes because multiple levels of quoting/unquoting are going on there, and different escape styles (Bash would want backslashes, while PowerShell uses the backtick as escape character). However, I suspect that you want those double quotes in order to preserve the backslashes in the path? That would not work because Unix shells interpret backslashes as escape characters even within double-quoted arguments, you would have to single-quote it to fix it. But then, you could simply pass on the command-line arguments, preserving them rather than letting the shell interpolate them. In your use case, it would probably suffice to surround the #! /bin/sh
apksigner=$ANDROID_HOME/build-tools/30.0.3/apksigner.bat
$apksigner "$@" |
Beta Was this translation helpful? Give feedback.
-
Setup
defaults?
to the issue you're seeing?
NO
Details
I start the git shell within PowerShell.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Putting now above functionality into a shell script called
apksigner.sh
:And calling finally the script with the same arguments:
./apksigner.sh sign --ks "C:\Program Files\Java\jdk1.8.0_131\jre\bin\KeyStore.jks" --ks-key-alias <my domain> --ks-pass pass:<my password> -v <some apk file>
.I expected that both commands lead to the same result.
The first command works. However, outsourcing the functionality into a script fails, because the quotation marks of
the windows path (see parameter
--ks
) are dropped, leading to an invalid path. I could fix the problem by eitherwrapping
$@
in quotation marks or passing the specific parameter in quotation marks, i.e. adjusting the last line of the script as follows:$apksigner $1 $2 "$3" ...
($3
refers to the--ks
argument)Is this due to the automatic path resolving incorporated in git bash or why are the quotation marks dropped?
URL to that repository to help us with testing?
NO.
Beta Was this translation helpful? Give feedback.
All reactions