Re asking for a variable after execution in bash (like an alternative to goto) [closed]

僤鯓⒐⒋嵵緔 提交于 2021-02-05 12:10:36

问题


I'm reformulating a bit better my previous question from today.

So basically, I have a bash script where i have

variable=$(zenity list dialog)

if test $variable = "something i've checked in zenity"
then
  run command & restart the script
elif...
  ...another command, etc...
fi

Where I have "restart the script", before a simple exec $0 was enough as a workaround, but I had to change the script and it's no longer working.

Now because I was doing a weird workaround anyway where I was spamming the system with processes, and stuff was erroring out in the script due to this, I want to do it nicely.

I need the script to go back to refresh the $variable, so to re-call zenity and to re-execute the if/elif loops again.

Basically a simple goto-like statement, but within the if/elif statements, not at the end of the script (because some programs that I execute can hang).

From what I understand, something like case needs to be used instead?

来源:https://stackoverflow.com/questions/66003835/re-asking-for-a-variable-after-execution-in-bash-like-an-alternative-to-goto

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!