[英]bash shell script error: ambigious redirect
在以下代碼中,用功能封裝代碼塊時會出現問題。 顯示錯誤消息$1: ambigious redirect" is displayed.
while
循環逐行從input.txt
文件中讀取文本,並將其存儲在linesArray
數組中。
“ while”循環中的for
循環遍歷索引為0的linesArray
數組的所有元素,然后執行case語句,該語句將數組的元素與有效的mips運算符進行比較。
function mnemonicCheck {
while read line; do
linesArray=($line)
for e in ${linesArray[0]}
do
case $e in
"add")
;;
"sub")
;;
"addi")
;;
"lw")
;;
"sw")
;;
*)
echo "invalid operator used. Valid operators are: add,sub,addi,lw,sw"
;;
esac
done
done < $1
}
#calling methods
checkArguments $1 $2 $3
mnemonicCheck
您調用mnemonicCheck
不帶任何參數,因此函數$1
為空字符串。
那你會期望什么
< $1
是什么意思? (我同意在這種情況下使用“模棱兩可”是一個奇怪的詞,但這並不是完全不正確的,因為人們無法確定是什么意思。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.