I want to:
Here is an sh
-compliant script. Comments are provided to explain what different parts of the script do.
I assumed it was okay to install snap
with the apt
package manager, because the OP did not specify how to install snap
.
#!/usr/bin/env sh
# Exit early if any command fails
set -e
installSnap() {
# Assumption: This script is run only on Debian-based Linux distributions
echo 'snap not installed, installing snap...'
sudo apt update
sudo apt install snapd
echo 'snap installed. Log out and back in again before using snap.'
}
# If snap is not installed, install snap and exit
command -v snap || { installSnap && echo 'Exiting install script.' && exit 0; }
# Install GIMP
echo 'Installing GIMP...'
snap install gimp
echo 'GIMP installed.'
# Prompt user for input, and store input in answer
printf 'Would you like to run GIMP (y/n)? '
read -r answer
# If answer begins with 'Y' or 'y', start gimp
# Run gimp in background with nohup so gimp will continue running after
# this script terminates
# We likely aren't interested in gimp's output, so redirect it to /dev/null
[ "$answer" != "${answer#[Yy]}" ] && nohup gimp > /dev/null 2>&1 &
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments