Don't know how to resolve this unexpected EOF error

Viewed 41

I'm new to bash and am wondering what the problem is with this? Says the error is on line 44 and line 47. A copy of the error:

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

This is my script so far:

#! /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

Any help would be appreciated!

2 Answers

In line 13, your echo need (") at the end of the line:

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

It should be as:

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

@Milad alredy found the missing quote.
When writing code, consider avoiding duplicate code. In this case consider

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
Related