私のbashスクリプトが私が尋ねなくてもプロンプトに応答するのはなぜですか?

私のbashスクリプトが私が尋ねなくてもプロンプトに応答するのはなぜですか?

パッケージを削除してユーザーモードで再インストールしたいです。flatpak list行の最初の単語がパッケージのフルネームである手動で編集されたリストがあります。

名前を印刷するスクリプトを作成でき、名前が正しいです。flatpak uninstallこの名前を使用して手動で実行でき、機能します。

ただし、次のループを実行すると(明確にするためにインストール部分を削除しました)、スクリプトはオプションを提供せず、すべてのプロンプトに否定的な応答を提供します。

#!/bin/bash
while read line
do
app_name=$(echo "$line" | awk '{print $1}')
flatpak uninstall --delete-data "$app_name"
done < flatpaklist.txt

これは私が得た結果です。

        ID                                                 Branch           Op
 1.     io.github.Figma_Linux.figma_linux                  stable           r
 2.     io.github.Figma_Linux.figma_linux.Locale           stable           r
 3.     org.freedesktop.Platform.GL.default                20.08            r
 4.     org.freedesktop.Platform.Locale                    20.08            r
 5.     org.freedesktop.Platform.VAAPI.Intel               20.08            r
 6.     org.freedesktop.Platform                           20.08            r

Proceed with these changes to the system installation? [Y/n]: n
Similar installed refs found for ‘org.freedesktop.Platform’:

   1) runtime/org.freedesktop.Platform/x86_64/20.08 (system)
   2) runtime/org.freedesktop.Platform/x86_64/22.08 (system)
   3) All of the above

Which do you want to use (0 to abort)? [0-3]: 0
error: No ref chosen to resolve matches for ‘org.freedesktop.Platform’
Similar installed refs found for ‘org.freedesktop.Platform’:

   1) runtime/org.freedesktop.Platform/x86_64/20.08 (system)
   2) runtime/org.freedesktop.Platform/x86_64/22.08 (system)
   3) All of the above

Which do you want to use (0 to abort)? [0-3]: 0
error: No ref chosen to resolve matches for ‘org.freedesktop.Platform’
Similar installed refs found for ‘org.freedesktop.Platform.GL.default’:

   1) runtime/org.freedesktop.Platform.GL.default/x86_64/22.08-extra (system)
   2) runtime/org.freedesktop.Platform.GL.default/x86_64/22.08 (system)
   3) runtime/org.freedesktop.Platform.GL.default/x86_64/21.08 (system)
   4) runtime/org.freedesktop.Platform.GL.default/x86_64/20.08 (system)
   5) All of the above

ご覧のとおり、「n」または「0」という答えが入力されました。しかし、それは私の仕事ではないので、選択の余地はありません。

私もそれを試しましたyes | flatpak uninstall --delete-data "$app_name"。数字が必要な場合は、自動的に「0」と答え、「はい」または「いいえ」が必要な場合は「n」と答えます。

ベストアンサー1

おすすめ記事