0

私は bash で小さなスクリプトを作成しており、YADGUI ウィンドウの作成に使用しています。問題の機能では、ユーザーは検索したいソフトウェアの名前を入力できます。ifユーザーが名前を入力したかどうかを確認する条件を追加しました。エントリ フィールドが空のままの場合、スクリプトは、フィールドに入力する必要があることを示すメッセージを表示します。

上記の部分は機能しています。私が作業できないのは、同じYADGUI を呼び出しているため、ユーザーはメイン GUI に戻らずにソフトウェア名を入力できます。

これがフル機能です。

ftNameRepo(){
    local text=""
    text+="Enter the name of the sofwate you want to search\n"
    text+="in the official repository."

    local nme=(
        yad --form --align-buttons --use-interp --title="Software Name" \
        --text="$text" --field="Name:" --button="Search!gtk-search!Click to search":0
    )
    local name="$("${nme[@]}" | cut -d '|' -f1)"

    if [[ name -ne "" ]]; then

        case "$?" in
            0) RunInTerminal pacman -Ss "$name" ;;
        esac

    else
        yad --image="error" --text="Name fiels cannot be empty" \
        --title="Empty Field" --text-align=left --width=300 \
        --button="Close!gtk-close!Click to close.":0

      #This part I'm trying to go back to the enter software screen. After clicking on ok button of the above message.
        case "$?" in
            0) $(nme) ;;
        esac
    fi
}
export -f sftNameRepo

これがif条件で、

if [[ name -ne "" ]]; then

        case "$?" in
            0) RunInTerminal pacman -Ss "$name" ;;
        esac

    else
        yad --image="error" --text="Name fiels cannot be empty" \
        --title="Empty Field" --text-align=left --width=300 \
        --button="Close!gtk-close!Click to close.":0

      #This part I'm trying to go back to the enter software screen. After clicking on ok button of the above message.
        case "$?" in
            0) $(nme) ;;
        esac
    fi

これは、空であるというメッセージをポップしている部分であり、ユーザーが「OK」ボタンをクリックすると、local nme実行または呼び出されます。

このようにしようとして(他の多くの方法を試しました)、

else
        yad --image="error" --text="Name fiels cannot be empty" \
        --title="Empty Field" --text-align=left --width=300 \
        --button="Close!gtk-close!Click to close.":0

      #This part I'm trying to go back to the enter software screen. After clicking on ok button of the above message.
        case "$?" in
            0) $(nme) ;;
        esac
4

0 に答える 0