I build the script that is mandatory for use in GUI interface (for a reason). The script is designed to relaunch itself in gnome terminal in all conditions.

The basic stub of the script is looking like that:

if [[ $1 = "-tl" ]]
    read VARIABLE

    gnome-terminal -x bash -c "${PWD}/the-script -tl"

The script by default might be launched by "Execute in Terminal" command of Nautilus etc. or by the command line (see shell).

Once the script is launched, it designed to relaunch itself back in Gnome Terminal in any conditions.

The problem goes while the script is mooved outside the user directory, it runs and stops immidiately, popping up the terminal window for a second (while correctly relaunched, it must at least stop by the read variable command).

Using string like that achieves same result:

gnome-terminal -x bash -c "./the-script -tl"

Making the bash directly treat the argument as bash script name instead of command, gives correct result outside user directory, but has broken functionality back in user dir:

gnome-terminal -x bash "${PWD}/the-script" -tl

It turns out that both solutions are not universal!

1 Answer 1


The first line should be

if [[ $1 == "-tl" ]]

...otherwise you are setting the value of $1.

And the term line should be

gnome-terminal -x "$0" -tl

...$0 is the path to the running script

  • 4
    From the [[ expression ]] subsection of man bash: The = operator is equivalent to ==. Jul 3, 2020 at 22:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .