commit 1a2a08314cf70e4980f373fb00774e5b5f52d3bd
parent 0967c9dab648005ae871be1d9604221e1b7325b0
Author: Remy Noulin <loader2x@gmail.com>
Date: Sat, 26 Sep 2020 13:43:25 +0200
fix bug spliting argruments
Call a program with quotes in arguments was spliting the string into multiple arguments:
./example.c "a b" was interpreted as ./example.c a b
sheepy now adds quotes around all arguments to keep the same number of arguments
src/sheepy.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
Diffstat:
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/sheepy.c b/src/sheepy.c
@@ -823,11 +823,16 @@ int MAIN(int ARGC, char** ARGV) {
// debug program with parameters on command line
rangeFrom(i, 3, argc)
pushG(paramL, argv[i]);
- // create parameter string
- char *params = joinSG(paramL, " ");
+ // create parameter string for running the program in argv[1]
+ // add quotes to keep the same number of arguments
+ char *params = joinSG(paramL, "\" \"");
if (!params) {
emptyS(params);
}
+ else {
+ prependG(¶ms, "\"");
+ pushG(¶ms, "\"");
+ }
char *debugCommand = formatS("%s %s %s", debuggerCmd, buildExePath, params);;
system(debugCommand);
@@ -1166,11 +1171,16 @@ int MAIN(int ARGC, char** ARGV) {
rangeFrom(i, 2, argc)
pushG(paramL, argv[i]);
- // create parameter string
- char *params = joinSG(paramL, " ");
+ // create parameter string for running the program in argv[1]
+ // add quotes to keep the same number of arguments
+ char *params = joinSG(paramL, "\" \"");
if (!params) {
emptyS(params);
}
+ else {
+ prependG(¶ms, "\"");
+ pushG(¶ms, "\"");
+ }
// detect execute bit
// if yes then run (run)