How to pass command line parameters with quotes stored in single variable?

前端 未结 5 1120
闹比i
闹比i 2021-01-07 03:58

I want to call external application from shell script, but this shell script gets parameters (from other script) in a single variable. All was OK until I did not have to use

5条回答
  •  死守一世寂寞
    2021-01-07 04:19

    script

    pass() {
      echo 'Result with "$@"'
      sh_param "$@"
    }
    
    sh_param() {
      for i in "$@"
      do
        echo Param: $i
      done
    }
    
    pass "single param" separate param
    

    result

    Result with "$@"
    Param: single param
    Param: separate
    Param: param
    

提交回复
热议问题