0

I have a script which unexplainably forks a new Terminal instance on some Linux distributions... I'd rather it doesn't do this. Oddly, when I run the script directly (./install.sh) the additional Terminal instance doesn't get created.

curl qz.sh | bash # warning this will install a Linux Desktop App you may not want :)
  • On MacOS Mojave: Works normally
  • On Ubuntu 22.04: Works normally in a VM
  • On Fedora 34: Works normally in a VM
  • On Ubuntu 20.10: Reportedly spawns a new terminal
  • On Manjaro XFCE: Works ok until it reaches the sudo ... command in the script and spawns a new Terminal instance

Full source code here.

The code in question is as follows:

# Install using unattended techniques: https://github.com/qzind/tray/wiki/deployment
echo -e "Download successful, beginning the install..."
case $OSTYPE in
    "darwin"*)
        # Assume .pkg (installer) for MacOS
        sudo installer -pkg "$TEMP_FILE" -target /
        ;;
    *)
        # Assume .run (makeself) for others
        if which sudo >/dev/null 2>&1 ; then
            # use "sudo" if available
            sudo bash "$TEMP_FILE" -- -y
        else
            # fallback to "su -c"
            su root -c "bash '$TEMP_FILE' -- -y"
        fi
        ;;
esac

Question: Why does this spawn a new Terminal instance in some environments and how can I prevent this from happening?

1 Answer 1

1

The reason a terminal isn't created when running the installer directly is that makeself uses tty -s to determine whether it's already running in a terminal or not, see the source code on GitHub. When running curl qz.sh | bash you're opening a pipe that's not there when running the script directly, causing the tty -s test to fail.

To prevent the terminal from being opened, you can use makeself's --nox11 flag, citing the README:

--nox11 : Disable the automatic spawning of a new terminal in X11.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.