Bash script to receive and repass quoted parameters

前端 未结 2 1651
清酒与你
清酒与你 2020-11-29 17:23

I\'m trying to get quoted parameters of a bash script to safely be received by a nested script. Any ideas?

test.sh

#!/bin/bash
echo $*
bash myecho.sh         


        
2条回答
  •  自闭症患者
    2020-11-29 17:48

    #!/bin/bash
    echo $*
    bash myecho.sh "$@"
    

    Note the "$@" construct is not bash specific and should work with any POSIX shell (it does with dash at least). Note also that given the output you want, you don't need the extra level of quoting at all. I.E. just call the above script like:

    ./test.sh 1 2 "3 4"
    

提交回复
热议问题