From b62b14da31e39c249ecaf241194e449222dc8d9d Mon Sep 17 00:00:00 2001 From: Nyx <144965845+nnyyxxxx@users.noreply.github.com> Date: Wed, 18 Sep 2024 20:39:03 -0400 Subject: [PATCH] Replace echos with printf and general improvements (#482) Co-authored-by: nnyyxxxx Co-authored-by: Chris Titus --- tabs/common-script.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tabs/common-script.sh b/tabs/common-script.sh index 84ff660d..769ae905 100644 --- a/tabs/common-script.sh +++ b/tabs/common-script.sh @@ -20,13 +20,13 @@ checkAURHelper() { for helper in ${AUR_HELPERS}; do if command_exists "${helper}"; then AUR_HELPER=${helper} - echo "Using ${helper} as AUR helper" + printf "Using ${helper} as AUR helper" AUR_HELPER_CHECKED=true return 0 fi done - echo "Installing yay as AUR helper..." + printf "%b\n" "${YELLOW}Installing yay as AUR helper...${RC}" "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/yay-bin.git && "$ESCALATION_TOOL" chown -R "$USER":"$USER" ./yay-bin cd yay-bin && makepkg --noconfirm -si @@ -49,7 +49,7 @@ checkEscalationTool() { for tool in ${ESCALATION_TOOLS}; do if command_exists "${tool}"; then ESCALATION_TOOL=${tool} - echo "Using ${tool} for privilege escalation" + printf "Using ${tool} for privilege escalation" ESCALATION_TOOL_CHECKED=true return 0 fi @@ -65,7 +65,7 @@ checkCommandRequirements() { REQUIREMENTS=$1 for req in ${REQUIREMENTS}; do if ! command_exists "${req}"; then - echo "${RED}To run me, you need: ${REQUIREMENTS}${RC}" + printf "%b\n" "${RED}To run me, you need: ${REQUIREMENTS}${RC}" exit 1 fi done @@ -77,7 +77,7 @@ checkPackageManager() { for pgm in ${PACKAGEMANAGER}; do if command_exists "${pgm}"; then PACKAGER=${pgm} - echo "Using ${pgm}" + printf "Using ${pgm}" break fi done @@ -94,14 +94,14 @@ checkSuperUser() { for sug in ${SUPERUSERGROUP}; do if groups | grep -q "${sug}"; then SUGROUP=${sug} - echo "Super user group ${SUGROUP}" + printf "Super user group ${SUGROUP}" break fi done ## Check if member of the sudo group. if ! groups | grep -q "${SUGROUP}"; then - echo "${RED}You need to be a member of the sudo group to run me!${RC}" + printf "%b\n" "${RED}You need to be a member of the sudo group to run me!${RC}" exit 1 fi } @@ -110,7 +110,7 @@ checkCurrentDirectoryWritable() { ## Check if the current directory is writable. GITPATH="$(dirname "$(realpath "$0")")" if [ ! -w "$GITPATH" ]; then - echo "${RED}Can't write to $GITPATH${RC}" + printf "%b\n" "${RED}Can't write to $GITPATH${RC}" exit 1 fi }