我写了一个shell脚本来听音乐(在使用el capitan的mac上),但遇到了一些问题 代码是:
#!/bin/sh
KEYF="true";
while [ "$KEYF" == "true" ] ;
KEYS="true";
do echo "Pick a song:\n" ;
select SONG in Music_Path/* ;
do echo "You chose to listen to ${SONG}" ;
break;
done;
while [ "$KEYS" == "true" ];
do mpv "${SONG}" ;
echo "Do you want to repeat this song; if so, enter true; if not, enter false.";
select KEYS in "true" "false";
do echo "You picked $KEYS";
break;
done ;
done ;
echo "Do you want to pick a new song; if so, enter true; if not, enter false.";
select KEYF in "true" "false";
do echo "You picked $KEYF";
break;
done;
done
一切正常,但是在我为KEYF
和KEYS
选择了false之后,该过程循环回来并要求我再次选择一首歌。是不是第一个while
循环来阻止这种行为?
真诚的感谢您的帮助。
修改
根据@ 123的评论,问题是KEYS="true";
介于第一个和do
之间。