Execute a bash command using script variable, Which contains path with space to the executable tool?
I am writing a small script which will generate the signed apk.
I have android build tools located at
C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/
Within these build tools folder 27.0.3
there is apksigner.bat
file which is the tool to sign an apk file.
I am copying this file in an array which contains a set of commands for me,
cmd[1]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat"
Actual signing operation happens using the command as below,
"${cmd[1]}" sign --ks "$PATH_TO_JKS_KEY" --out "$outputfile" "$inputfile"
Above command fails with the following message,
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
I think the problem is space between Fname Lname in the path to the command.
Surprisingly the other command works exactly in this way, as follows
cmd[0]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign"
"${cmd[0]}" -v -p 4 "$inputfilepath" "$outputfilepath"
This command path also has space between Fname & Lname.
Environment:
Windows 10
Command runs under git bash.
What might be wrong?
Update 1
As per the suggestion of Nahuel Fouilleul in the comment section, I added below code prior to my erroneous code
printf "'%s'n" "${cmd[@]}"
set -x
Following result came onto the screen,
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign'
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
+ echo ''
+ echo 'ANDROID Apk sign operation in progress'
ANDROID Apk sign operation in progress
+ 'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat' sign --ks 'C:ProjectsDummyapp/my-app/upload_android.jks' --out '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release.apk' '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release-zipalign.apk'
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
+ '[' 1 '!=' 0 ']'
+ echo 'Android apk signing failed'
Android apk signing failed
+ abortRestore gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
+ git reset --hard gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
HEAD is now at gyh5dd9 This is restore point test case
+ '[' 0 '!=' 0 ']'
+ exit 1
Update 2
After comments by Charles Duffy I tried running on Mac it worked well also I came across one more problem as I used windows editor software ( Notepad++ ) which added a r (carriage return) to the end of every line, causing script execution failure ( Link to carriage return issue ), So now I have decided to start working on the script on Mac machine instead of windows.
Important comment by Charles :
basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to the execv family of UNIX syscalls into a single string in a way the native-Windows called program will understand.
bash android-build
|
show 3 more comments
I am writing a small script which will generate the signed apk.
I have android build tools located at
C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/
Within these build tools folder 27.0.3
there is apksigner.bat
file which is the tool to sign an apk file.
I am copying this file in an array which contains a set of commands for me,
cmd[1]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat"
Actual signing operation happens using the command as below,
"${cmd[1]}" sign --ks "$PATH_TO_JKS_KEY" --out "$outputfile" "$inputfile"
Above command fails with the following message,
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
I think the problem is space between Fname Lname in the path to the command.
Surprisingly the other command works exactly in this way, as follows
cmd[0]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign"
"${cmd[0]}" -v -p 4 "$inputfilepath" "$outputfilepath"
This command path also has space between Fname & Lname.
Environment:
Windows 10
Command runs under git bash.
What might be wrong?
Update 1
As per the suggestion of Nahuel Fouilleul in the comment section, I added below code prior to my erroneous code
printf "'%s'n" "${cmd[@]}"
set -x
Following result came onto the screen,
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign'
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
+ echo ''
+ echo 'ANDROID Apk sign operation in progress'
ANDROID Apk sign operation in progress
+ 'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat' sign --ks 'C:ProjectsDummyapp/my-app/upload_android.jks' --out '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release.apk' '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release-zipalign.apk'
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
+ '[' 1 '!=' 0 ']'
+ echo 'Android apk signing failed'
Android apk signing failed
+ abortRestore gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
+ git reset --hard gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
HEAD is now at gyh5dd9 This is restore point test case
+ '[' 0 '!=' 0 ']'
+ exit 1
Update 2
After comments by Charles Duffy I tried running on Mac it worked well also I came across one more problem as I used windows editor software ( Notepad++ ) which added a r (carriage return) to the end of every line, causing script execution failure ( Link to carriage return issue ), So now I have decided to start working on the script on Mac machine instead of windows.
Important comment by Charles :
basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to the execv family of UNIX syscalls into a single string in a way the native-Windows called program will understand.
bash android-build
it seems the command is not exactly run as it is in question, can you add following commands before"${cmd[1]}" ...
call :printf "'%s'n" "${cmd[@]}"
andset -x
– Nahuel Fouilleul
Nov 20 '18 at 13:03
@NahuelFouilleul pls have look at the updated question, Thanks
– pcj
Nov 20 '18 at 13:19
printf '%sn'
isn't particularly useful -- it just provides the literal content; literal quotes will at least allow CR detection, but not all nonprintable/invisible characters are carriage returns. If the shell is bash,printf '%qn' "$@"
is much more relevant/applicable, insofar as it emits the content with nonprintable values visually distinguished. (Baseline POSIX/bin/sh
doesn't support that operation, so whether the shell really is bash is pertinent).
– Charles Duffy
Nov 20 '18 at 13:31
...the other thing is that this smells like we have some platform-specific weirdness here. On a real UNIXlike platform,'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
wouldn't be treatingC:/Users/Fname
as its own word. Do you have a Linux VM? Might make sense just to use it, and get Windows out-of-the-picture.
– Charles Duffy
Nov 20 '18 at 13:34
1
...basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to theexecv
family of UNIX syscalls into a single string in a way the native-Windows called program will understand.
– Charles Duffy
Nov 20 '18 at 13:38
|
show 3 more comments
I am writing a small script which will generate the signed apk.
I have android build tools located at
C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/
Within these build tools folder 27.0.3
there is apksigner.bat
file which is the tool to sign an apk file.
I am copying this file in an array which contains a set of commands for me,
cmd[1]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat"
Actual signing operation happens using the command as below,
"${cmd[1]}" sign --ks "$PATH_TO_JKS_KEY" --out "$outputfile" "$inputfile"
Above command fails with the following message,
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
I think the problem is space between Fname Lname in the path to the command.
Surprisingly the other command works exactly in this way, as follows
cmd[0]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign"
"${cmd[0]}" -v -p 4 "$inputfilepath" "$outputfilepath"
This command path also has space between Fname & Lname.
Environment:
Windows 10
Command runs under git bash.
What might be wrong?
Update 1
As per the suggestion of Nahuel Fouilleul in the comment section, I added below code prior to my erroneous code
printf "'%s'n" "${cmd[@]}"
set -x
Following result came onto the screen,
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign'
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
+ echo ''
+ echo 'ANDROID Apk sign operation in progress'
ANDROID Apk sign operation in progress
+ 'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat' sign --ks 'C:ProjectsDummyapp/my-app/upload_android.jks' --out '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release.apk' '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release-zipalign.apk'
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
+ '[' 1 '!=' 0 ']'
+ echo 'Android apk signing failed'
Android apk signing failed
+ abortRestore gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
+ git reset --hard gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
HEAD is now at gyh5dd9 This is restore point test case
+ '[' 0 '!=' 0 ']'
+ exit 1
Update 2
After comments by Charles Duffy I tried running on Mac it worked well also I came across one more problem as I used windows editor software ( Notepad++ ) which added a r (carriage return) to the end of every line, causing script execution failure ( Link to carriage return issue ), So now I have decided to start working on the script on Mac machine instead of windows.
Important comment by Charles :
basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to the execv family of UNIX syscalls into a single string in a way the native-Windows called program will understand.
bash android-build
I am writing a small script which will generate the signed apk.
I have android build tools located at
C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/
Within these build tools folder 27.0.3
there is apksigner.bat
file which is the tool to sign an apk file.
I am copying this file in an array which contains a set of commands for me,
cmd[1]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat"
Actual signing operation happens using the command as below,
"${cmd[1]}" sign --ks "$PATH_TO_JKS_KEY" --out "$outputfile" "$inputfile"
Above command fails with the following message,
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
I think the problem is space between Fname Lname in the path to the command.
Surprisingly the other command works exactly in this way, as follows
cmd[0]="C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign"
"${cmd[0]}" -v -p 4 "$inputfilepath" "$outputfilepath"
This command path also has space between Fname & Lname.
Environment:
Windows 10
Command runs under git bash.
What might be wrong?
Update 1
As per the suggestion of Nahuel Fouilleul in the comment section, I added below code prior to my erroneous code
printf "'%s'n" "${cmd[@]}"
set -x
Following result came onto the screen,
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/zipalign'
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
+ echo ''
+ echo 'ANDROID Apk sign operation in progress'
ANDROID Apk sign operation in progress
+ 'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat' sign --ks 'C:ProjectsDummyapp/my-app/upload_android.jks' --out '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release.apk' '/c/Users/Fname Lname/Desktop/cmd_test/test/20-Nov-2018_18-36-14_IST/my-app-release-zipalign.apk'
'C:UsersFname' is not recognized as an internal or external command,
operable program or batch file.
+ '[' 1 '!=' 0 ']'
+ echo 'Android apk signing failed'
Android apk signing failed
+ abortRestore gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
+ git reset --hard gyh5dd9e65ba174f44cd2fe92c4093ed240cda06
HEAD is now at gyh5dd9 This is restore point test case
+ '[' 0 '!=' 0 ']'
+ exit 1
Update 2
After comments by Charles Duffy I tried running on Mac it worked well also I came across one more problem as I used windows editor software ( Notepad++ ) which added a r (carriage return) to the end of every line, causing script execution failure ( Link to carriage return issue ), So now I have decided to start working on the script on Mac machine instead of windows.
Important comment by Charles :
basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to the execv family of UNIX syscalls into a single string in a way the native-Windows called program will understand.
bash android-build
bash android-build
edited Nov 21 '18 at 9:33
pcj
asked Nov 20 '18 at 12:29
pcjpcj
1,26411441
1,26411441
it seems the command is not exactly run as it is in question, can you add following commands before"${cmd[1]}" ...
call :printf "'%s'n" "${cmd[@]}"
andset -x
– Nahuel Fouilleul
Nov 20 '18 at 13:03
@NahuelFouilleul pls have look at the updated question, Thanks
– pcj
Nov 20 '18 at 13:19
printf '%sn'
isn't particularly useful -- it just provides the literal content; literal quotes will at least allow CR detection, but not all nonprintable/invisible characters are carriage returns. If the shell is bash,printf '%qn' "$@"
is much more relevant/applicable, insofar as it emits the content with nonprintable values visually distinguished. (Baseline POSIX/bin/sh
doesn't support that operation, so whether the shell really is bash is pertinent).
– Charles Duffy
Nov 20 '18 at 13:31
...the other thing is that this smells like we have some platform-specific weirdness here. On a real UNIXlike platform,'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
wouldn't be treatingC:/Users/Fname
as its own word. Do you have a Linux VM? Might make sense just to use it, and get Windows out-of-the-picture.
– Charles Duffy
Nov 20 '18 at 13:34
1
...basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to theexecv
family of UNIX syscalls into a single string in a way the native-Windows called program will understand.
– Charles Duffy
Nov 20 '18 at 13:38
|
show 3 more comments
it seems the command is not exactly run as it is in question, can you add following commands before"${cmd[1]}" ...
call :printf "'%s'n" "${cmd[@]}"
andset -x
– Nahuel Fouilleul
Nov 20 '18 at 13:03
@NahuelFouilleul pls have look at the updated question, Thanks
– pcj
Nov 20 '18 at 13:19
printf '%sn'
isn't particularly useful -- it just provides the literal content; literal quotes will at least allow CR detection, but not all nonprintable/invisible characters are carriage returns. If the shell is bash,printf '%qn' "$@"
is much more relevant/applicable, insofar as it emits the content with nonprintable values visually distinguished. (Baseline POSIX/bin/sh
doesn't support that operation, so whether the shell really is bash is pertinent).
– Charles Duffy
Nov 20 '18 at 13:31
...the other thing is that this smells like we have some platform-specific weirdness here. On a real UNIXlike platform,'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
wouldn't be treatingC:/Users/Fname
as its own word. Do you have a Linux VM? Might make sense just to use it, and get Windows out-of-the-picture.
– Charles Duffy
Nov 20 '18 at 13:34
1
...basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to theexecv
family of UNIX syscalls into a single string in a way the native-Windows called program will understand.
– Charles Duffy
Nov 20 '18 at 13:38
it seems the command is not exactly run as it is in question, can you add following commands before
"${cmd[1]}" ...
call : printf "'%s'n" "${cmd[@]}"
and set -x
– Nahuel Fouilleul
Nov 20 '18 at 13:03
it seems the command is not exactly run as it is in question, can you add following commands before
"${cmd[1]}" ...
call : printf "'%s'n" "${cmd[@]}"
and set -x
– Nahuel Fouilleul
Nov 20 '18 at 13:03
@NahuelFouilleul pls have look at the updated question, Thanks
– pcj
Nov 20 '18 at 13:19
@NahuelFouilleul pls have look at the updated question, Thanks
– pcj
Nov 20 '18 at 13:19
printf '%sn'
isn't particularly useful -- it just provides the literal content; literal quotes will at least allow CR detection, but not all nonprintable/invisible characters are carriage returns. If the shell is bash, printf '%qn' "$@"
is much more relevant/applicable, insofar as it emits the content with nonprintable values visually distinguished. (Baseline POSIX /bin/sh
doesn't support that operation, so whether the shell really is bash is pertinent).– Charles Duffy
Nov 20 '18 at 13:31
printf '%sn'
isn't particularly useful -- it just provides the literal content; literal quotes will at least allow CR detection, but not all nonprintable/invisible characters are carriage returns. If the shell is bash, printf '%qn' "$@"
is much more relevant/applicable, insofar as it emits the content with nonprintable values visually distinguished. (Baseline POSIX /bin/sh
doesn't support that operation, so whether the shell really is bash is pertinent).– Charles Duffy
Nov 20 '18 at 13:31
...the other thing is that this smells like we have some platform-specific weirdness here. On a real UNIXlike platform,
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
wouldn't be treating C:/Users/Fname
as its own word. Do you have a Linux VM? Might make sense just to use it, and get Windows out-of-the-picture.– Charles Duffy
Nov 20 '18 at 13:34
...the other thing is that this smells like we have some platform-specific weirdness here. On a real UNIXlike platform,
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
wouldn't be treating C:/Users/Fname
as its own word. Do you have a Linux VM? Might make sense just to use it, and get Windows out-of-the-picture.– Charles Duffy
Nov 20 '18 at 13:34
1
1
...basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to the
execv
family of UNIX syscalls into a single string in a way the native-Windows called program will understand.– Charles Duffy
Nov 20 '18 at 13:38
...basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to the
execv
family of UNIX syscalls into a single string in a way the native-Windows called program will understand.– Charles Duffy
Nov 20 '18 at 13:38
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393029%2fexecute-a-bash-command-using-script-variable-which-contains-path-with-space-to%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393029%2fexecute-a-bash-command-using-script-variable-which-contains-path-with-space-to%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
it seems the command is not exactly run as it is in question, can you add following commands before
"${cmd[1]}" ...
call :printf "'%s'n" "${cmd[@]}"
andset -x
– Nahuel Fouilleul
Nov 20 '18 at 13:03
@NahuelFouilleul pls have look at the updated question, Thanks
– pcj
Nov 20 '18 at 13:19
printf '%sn'
isn't particularly useful -- it just provides the literal content; literal quotes will at least allow CR detection, but not all nonprintable/invisible characters are carriage returns. If the shell is bash,printf '%qn' "$@"
is much more relevant/applicable, insofar as it emits the content with nonprintable values visually distinguished. (Baseline POSIX/bin/sh
doesn't support that operation, so whether the shell really is bash is pertinent).– Charles Duffy
Nov 20 '18 at 13:31
...the other thing is that this smells like we have some platform-specific weirdness here. On a real UNIXlike platform,
'C:/Users/Fname Lname/AppData/Local/Android/Sdk/build-tools/27.0.3/apksigner.bat'
wouldn't be treatingC:/Users/Fname
as its own word. Do you have a Linux VM? Might make sense just to use it, and get Windows out-of-the-picture.– Charles Duffy
Nov 20 '18 at 13:34
1
...basically, calling Windows applications with escaped names requires knowing how that specific application unescapes its command line, because on Windows, each program is responsible for parsing a string passed to it as a command line into its argument list; by contrast, on UNIX, programs are started with an array, not a single string... so a Windows portability layer needs to guess at how to change the array of separate strings passed to the
execv
family of UNIX syscalls into a single string in a way the native-Windows called program will understand.– Charles Duffy
Nov 20 '18 at 13:38