Bashスクリプトを正しく終了できません。

Bashスクリプトを正しく終了できません。

Bashでスクリプトを作成しました。

#!/bin/bash

zen(){
mark=$(zenity --scale \
    --text 'FREQUENCY' \
    --value=$la \
    --min-value=0\
    --max-value=5000 \
    --step=1)
}
la=500

echo "Script for shim. Regulary frequency"
zen
while [ true ] 
do

case $? in

    0) echo $mark
       la=$mark
       #zenity --notification --window-icon="info" --text="Thank you!" --timeout=1
       zen
    ;;
    1) 
       # exit 1
       # sl -e || break
       # break
       # return 1       
    ;;
esac 
done
echo "thanks for using!"

出口点を除いてうまくいきます。 #私が試したオプションの前には、「ご利用いただきありがとうございます!」代わりに、このスクリプトでは適切なシャットダウンは許可されていません。それ以外の場合、端末には何も表示されません。

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

^XThis option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

This option is not available. Please see --help for all possible usages.

.........................................

スクリプトを終了しようとすると、zenityに問題があるようです。エラーを探し、唯一合理的なアイデアはzenityをアップグレードすることでした。すでにアップグレードしていますが、新しい結果は出ませんでした...

それでは、どのように修正してこのスクリプトを正しく中断することができますか?

私のオペレーティングシステムはUbuntu Server 16.04です。

編集する

私のスクリプトを使用して、zenityからユーザーが「キャンセル」をクリックした瞬間まで繰り返される問題を解決したいと思います。

ベストアンサー1

$?最後のコマンド実行の終了状態です。あなたの場合、これはコマンドです(ループ条件で文字列が空でないことを[テストするために使用されます)。truewhile

$?明示的に使用する必要はほとんどありません。ただ

la=500
while
  mark=$(zenity --scale \
      --text 'FREQUENCY' \
      --value="$la" \
      --min-value=0 \
      --max-value=5000 \
      --step=1)
do
  echo "$mark"
  la=$mark
done

または簡単に:

mark=500
while
  mark=$(zenity --scale \
      --text 'FREQUENCY' \
      --value="$mark" \
      --min-value=0 \
      --max-value=5000 \
      --step=1)
do
  echo "$mark"
done

おすすめ記事