以下是我的腳本(片段)
#!/bin/bash
set -o errexit
set -o nounset
set -o xtrace
set -o pipefail
ARGUMENT=$1
我正在嘗試使用 cygwin bash 運行并出現以下錯誤。
C:\cygwin64\bin\bash.exe -l -c /cygdrive/c/test.sh ARGUMENT1
得到以下錯誤
set -o pipefail
/cygdrive/c/test.sh: line 8: $1: unbound variable
uj5u.com熱心網友回復:
您沒有將引數傳遞給test.sh,因為該引數不包含在-c您傳遞給的選項值中bash。只需添加引號即可解決此問題:
C:\cygwin64\bin\bash.exe -l -c "/cygdrive/c/test.sh ARGUMENT1"
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/348044.html
下一篇:bash處理多引號
