Bash
Bash 腳本問題
我正在編寫腳本…我不知道它有什麼問題…
!#/bin/bash while="true" while ($while == "true") do clear echo "What game would you like to play?" echo "1. Tetris (bastet)" read number -P "Enter Number:" if ( $number == "1" ) then bastet clear read again -P "Would you like to play another game? [y/n]:" if ($again == "n") then exit fi fi done
這是我的輸出(循環):
What game would you like to play? 1. Tetris (bastet)
沒有讀取命令的提示
這就是良好的程式碼表格格式在查看您的問題和錯誤方面有所不同的地方。問題是您的if 語句永遠不允許腳本跳出循環。此外,您還缺少一些迴聲以及 steeldriver 和 user4556274 指出的所有其他內容。
我並沒有真正重新編碼你寫的東西,所以你仍然可以感覺到你哪裡出錯了。
查看我的修訂:
#!/bin/bash flag="true" while [ $flag == "true" ]; do clear echo "What game would you like to play?" echo "1. Tetris (bastet)" read number -P "Enter Number:" if [ $number -eq "1" ]; then bastet fi clear echo "Would you like to play another game? [y/n]:" read again -P if [ $again -eq "n" ]; then exit 1 fi done