无法正确退出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

编辑

通过我的脚本,我希望实现从禅宗到用户单击“取消”的那一刻重复出现的问题。

斯蒂芬·查泽拉斯

$?是最后运行的命令的退出状态。在您的情况下,这就是[命令(您可以用来测试true字符串是否为非空作为while循环的条件)。

您几乎不需要$?显式使用做就是了

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

内含nohup的脚本无法正确退出

来自分类Dev

无法捕获 ctrl-c 以退出函数退出 bash 脚本

来自分类Dev

当软件无法正确安装时,脚本如何退出?

来自分类Dev

perl无法正确评估bash脚本

来自分类Dev

从使用$()的bash脚本退出

来自分类Dev

使用bash脚本SSH时无法正常退出

来自分类Dev

Bash脚本无法正确调用其他脚本

来自分类Dev

Bash脚本退出清理

来自分类Dev

bash脚本中的退出状态

来自分类Dev

Bash在脚本中退出sudo

来自分类Dev

通过ssh执行的bash脚本返回不正确的退出代码0

来自分类Dev

通过ssh执行的bash脚本返回不正确的退出代码0

来自分类Dev

python-virtualenv:无法正确运行bash脚本

来自分类Dev

Bash脚本无法正确处理npm命令

来自分类Dev

Bash脚本无法在Docker容器中正确执行

来自分类Dev

Collatz函数无法正确退出

来自分类Dev

python无法正确退出程序

来自分类Dev

Collatz函数无法正确退出

来自分类Dev

在脚本中退出bash命令而不退出脚本

来自分类Dev

确保即使子脚本退出,父bash脚本也不会退出

来自分类Dev

在脚本中退出bash命令而不退出脚本

来自分类Dev

Bash脚本的正确缩进

来自分类Dev

Bash脚本的正确缩进

来自分类Dev

退出整个脚本的正确方法是什么?

来自分类Dev

为什么在此bash脚本中无法获取命令的退出值?

来自分类Dev

从bash脚本退出,但保持进程运行

来自分类Dev

Bash脚本不会循环退出

来自分类Dev

Bash退出代码状态脚本错误

来自分类Dev

从bash调用R脚本时退出代码