我想要:
这是一个sh
兼容的脚本。提供了注释来解释脚本的不同部分的作用。
我认为snap
使用apt
包管理器安装是可以的,因为 OP 没有指定如何安装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 &
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句