I run bash scripts. I want to run them both from terminal, and from GUI with "Run in Terminal" and leave after run interactive bash
. Simply seeing output is explained here : add read -rn1
.
Problem X:
I want a "clean" solution, to have at the end same terminal with bash that I can close with one exit
if script is run from terminal and if from GUI. I can add bash -i
, but if run from terminal it would require two exit
to close the terminal. exec bash -i
resulted in same.
Is there a way in a script to check if it was started from GUI via "Run in Terminal"?
Added 1 per comment:
ps aux | grep aaaa # while script started from GUI was running
mint 53293 0.1 0.0 11216 3356 pts/3 Ss+ 21:58 0:00 /bin/bash /home/mint/aaaaa.sh
Noted the difference from one started from terminal is Ss+
instead of S+
.
env
for extra environment variables that are being passed when run this way. Though I doubt that will yield a portable solution as DEs each tend to do their own thing.bash
script from the GUI, and while it is running startps aux | less
in another terminal window. Look through that list of processes, and find the line(s) that show the name of your script - or add agrep
pipe onto theps
command above. Add that line(s) to your question.