如何将 break 语句放入 korn 脚本中 switch case 内的条件中

How to put break statement inside a condition which is inside a switch case in korn script

我正在编写一个 korn 脚本来处理一些 fixed/user 提供的输入。我无法 运行 这个脚本,因为我收到语法错误 `)' unexpected。我在想这是因为我在 if 语句中使用了 break,其中 if 在 switch case 中。我上周刚刚开始编写脚本,非常感谢这方面的任何帮助。 P.S 使用 korn 脚本是有原因的。

  #!/usr/bin/ksh93

  typeset -A fileset_list               #fileset_list is associative

  fileset_list=([All filesets]="A B C D E"
           [A]=AA
           [B]=BB
           [C]="CC CCC CCCC CCCC"
           [D]=DD
           [E]="EE EEE EEEE EEEE EEEEE"
          )

        fileset="All filesets"
        echo "Recent update has found following unsupported filesets on the system:\n${fileset_list["All filesets"]}"
        echo "Do you want to delete all the listed filesets along with their dependencies Y/N"
        while true; do
                read yn
                case $yn in
                [Yy]* )
                        set -A delete_list ${fileset_list["All filesets"]}
                        uninstall_fun
                        break;;

                [Nn]* )
                        echo "Do you want to delete the partial list Y/N"
                        while true; do
                                read y_n
                                case $y_n in
                                [Yy]* ) echo "Enter the space separated filesets from the above list for deletion"
                                        read user_list
                                        echo "You have entered $user_list\nIs the list correct Y/N"
                                        read selection

                                        if [[ $selection == [Yy]* ]]
                                        then
                                                set -A delete_list $user_list
                                                uninstall_fun
                                                break;; #<<<<ISSUE
                                        else
                                                echo "Do you want to re-enter list Y/N" #<<<<<need this to go back and read y_n
                                        fi

                        #               break;;
                                [Nn]* )
                                        break;;

                                    * ) echo "Please answer yes(y) or no(n).";;

                                esac
                        done

                        break;;
                * ) echo "Please answer yes(y) or no(n).";;
                esac
        done

uninstall_fun(){
 echo "In uninstall_fun"
}

每个case块的末尾使用;;。您在 if 语句中间有一个,但 case 块尚未完成。
break;; # <<<<ISSUE 行应该变成 break # without ;;,
# break;; 行应该是 ;;

[Yy]* ) echo "Enter the space separated filesets from the above list for deletion"
        read user_list
        echo "You have entered $user_list\nIs the list correct Y/N"
        read selection

        if [[ $selection == [Yy]* ]]
        then
           set -A delete_list $user_list
           uninstall_fun
           break # Without ;;
        else
           echo "Do you want to re-enter list Y/N" #<<<<<need this to go back and read y_n
        fi

        ;; # Needed here
[Nn]* )