Shell脚本 - 没有回声,没有错误

问题描述 投票:0回答:1

我不确定为什么我没有从这个脚本中收到任何错误或任何回显的信息。这是我们应该纠正剧本中的错误的练习之一。我只需要轻推一下,指出我正确的方向。

#!/bin/bash
clear
echo 

while [ "$CHOICE" = "y" ]
do

    # Rocket ship count down code
    for num in {1..5}
    do
        echo "$num ..."
        sleep 1
    done

    echo
    echo -n 'We have main engine start.'

    # Rocket ship powering up
    for num in {1..3}
    do
        echo -n ". "
        sleep 1
    done
    # End rocket ship powering up loop

    echo -e '\e[1;31mlift off!\e[0m'
    echo

    # Loop to build rocket ship
    ################################################## Do not alter the code between these hash marks ###################################################
    for rocket_ship_part in  '\e[1;30m    A   \e[0m' '\e[1;30m   / \  \e[0m' '\e[1;30m   |=|  \e[1;30m' '\e[1;30m   |\e[1;31mU\e[0m\e[1;30m|' \
    '\e[1;30m   |\e[1;34mS\e[0m\e[1;30m|' '\e[1;30m   |\e[1;32mA\e[0m\e[1;30m|' '\e[1;30m  _|=|_  ' '\e[1;30m / | | \ ' '\e[1;30m | \|/ | ' \
    '\e[1;30m |/"\e[1;31m"\e[0m"\| ' '\e[1;31m   """ \e[0m' '\e[1;31m   """ \e[0m' '\e[1;31m    " \e[0m' '\e[1;31m    " \e[0m' '\e[1;31m    . \e[0m' \
    '\e[1;31m    . \e[0m' '\e[1;31m    . \e[0m' '\e[0;31m    . \e[0m' '\e[0;31m    . \e[0m' '\e[0;30m    . \e[0m' '\e[0;30m    . \e[0m'
    ################################################## Do not alter the code between these hash marks ###################################################
    do
        echo -e "$rocket_ship_part"
        sleep 1
    done

    # Up, up and away!
    for altitude in {1..30}
    do
        echo
        sleep 0.5
    done
    clear
    echo 'To the stars and beyond!'
    echo
    echo -n "Do ypu want to launch the rocket again? (y/n) "
    read CHOICE
    clear
done
linux bash for-loop sh
1个回答
0
投票

$CHOICE绝不是y,所以它永远不会进入while循环。

© www.soinside.com 2019 - 2024. All rights reserved.