不知道如何解决此意外的EOF错误



我是bash的新手,想知道这有什么问题?说错误在第44行和第47行。错误的副本:

unexpected EOF while looking for matching `"'
syntax error: unexpected end of file

到目前为止,这是我的脚本:

#! /usr/bin/bash
#Basic setup for fedora. Updates and upgrades, then adds rpm fusion repos
dnf update
dnf upgrade
dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf update
dnf upgrade
#Now, for some basic software.
if ! command -v google-chrome &> /dev/null
then
echo "Google chrome is not installed! Proceeding to install...
dnf install google-chrome-stable
else
echo "Google chrome is already installed. Skipping..."
fi
if ! command -v emacs &> /dev/null
then
echo "Emacs is not installed! Proceeding to install..."
dnf install emacs
else
echo "Emacs is already installed. Skipping..."
fi
if ! command -v vim &> /dev/null
then
echo "Vim is not installed! Proceeding to install..."
dnf install vim
else
echo "Vim is already installed. Skipping..."
fi
if ! command -v qbittorrent /dev/null
then
echo "Qbittorrent is not installed! Proceeding to install..."
dnf install qbittorrent
else
echo "Qbittorrent is already installed. Skipping..."
fi
if ! command -v steam &> /dev/null
then
echo "Steam is not installed! Proceeding to install..."
dnf install steam
else
echo "Steam is already installed. Skipping..."
exit
fi

任何帮助都将不胜感激!

在第13行中,您的回波需要("(在该行的末尾:

echo "Google chrome is not installed! Proceeding to install... <-

它应该是:

echo "Google chrome is not installed! Proceeding to install..." <-

@Milad已经找到了丢失的引号
编写代码时,请考虑避免重复代码。在这种情况下,考虑

install_when_needed () {
checkname="${1%-stable}"
displayname="$(sed -r 's/./U&/;s/-/ /g' <<< ${checkname})"
if ! command -v "${checkname}" &> /dev/null
then
echo "${displayname} is not installed! Proceeding to install..."
dnf install "$1"
else
echo "${displayname} is already installed. Skipping..."
fi
}
for prog in google-chrome-stable emacs vim qbittorrent steam; do
install_when_needed "${prog}"
done

最新更新