retaining quotes in bash correctly
I am trying to pass arguments from a bash script to an executable and one
of them contains spaces. I have been searching how to solve this, but I
cannot find the right way to do it. Minimal example with a script called
first and a script called second.
first script:
#!/bin/bash
# first script
ARGS="$@"
./second $ARGS
second script:
#!/bin/bash
# second script
echo "got $# arguments"
Now if I run it like this, I get the following results:
$ ./first abc def
got 2 args
$ ./first "abc def"
got 2 args
$ ./first 'abc def'
got 2 args
How can I make it so, that the second script also only receives one argument?
No comments:
Post a Comment