readを使用してスクリプト内でコマンドを実行しようとしていますが、ユーザーがCtrl+Cを使用すると、コマンドの実行を停止したいのですが、スクリプトを終了しません。このようなもの:
#!/bin/bash
input=$1
while [ "$input" != finish ]
do
read -t 10 input
trap 'continue' 2
bash -c "$input"
done
unset input
ユーザーがCtrl+Cを使用する場合、入力の読み取りと他のコマンドの実行を継続してほしい。問題は、次のようなコマンドを使用する場合です。
while (true) do echo "Hello!"; done;
Ctrl+を1回入力すると機能しませんCが、数回入力すると機能します。