From a7e1b9fe7a48a6154995a0b58eddf1345a8c244d Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Tue, 2 Apr 2024 13:56:49 -0300 Subject: [PATCH] Fix shellcheck --- bin/portzap | 24 ++++++++++++------------ libexec/portzap/portzap-install | 13 ++++++------- libexec/portzap/portzap-pull | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/bin/portzap b/bin/portzap index 4abbaa0..0d78618 100755 --- a/bin/portzap +++ b/bin/portzap @@ -13,7 +13,7 @@ libexec=$(realpath "${rootdir}/../libexec/portzap") ## # Functions require_root() { - if [ $(id -u) -ne 0 ]; then + if [ "$(id -u)" != "0" ]; then echo "This command requires root privileges." exit 1 fi @@ -44,29 +44,29 @@ case $1 in "clone") require_dependency git require_membership_of _portzap - ${libexec}/portzap-clone "${giturl}" "${gitdir}" + "${libexec}"/portzap-clone "${giturl}" "${gitdir}" ;; "pull") require_dependency git require_membership_of _portzap - ${libexec}/portzap-pull "${gitdir}" + "${libexec}"/portzap-pull "${gitdir}" ;; "install") require_root require_dependency git - ${libexec}/portzap-install "${gitdir}" "${installdir}" "${revision}" + "${libexec}"/portzap-install "${gitdir}" "${installdir}" "${revision}" ;; "adduser") require_root - ${libexec}/portzap-adduser + "${libexec}"/portzap-adduser ;; *) - echo Usage: portzap COMMAND [OPTIONS] - echo - echo Commands: - echo -e " clone Clone the hardenedbsd ports tree." - echo -e " pull Pull updates from the hardenedbsd ports tree." - echo -e " install Install the ports tree into /usr/ports." - echo -e " adduser Add the portzap user, group and home directory." + printf "Usage: portzap COMMAND [OPTIONS]\n" + printf "\n" + printf "Commands:\n" + printf " clone Clone the hardenedbsd ports tree.\n" + printf " pull Pull updates from the hardenedbsd ports tree.\n" + printf " install Install the ports tree into /usr/ports.\n" + printf " adduser Add the portzap user, group and home directory.\n" ;; esac diff --git a/libexec/portzap/portzap-install b/libexec/portzap/portzap-install index 8fe37d9..6c504ce 100755 --- a/libexec/portzap/portzap-install +++ b/libexec/portzap/portzap-install @@ -2,15 +2,14 @@ set -ex gitdir=$1 installdir=$2 -revision=$3 excludes=".git .gitignore .hooks .arcconfig" -cd ${gitdir} +cd "${gitdir}" find -s . -maxdepth 1 \ - -exec cp -Rfv {} ${installdir} \; \ - -exec chown -R root:_portzap ${installdir}/{} \; \ - -exec chmod -R u=rwX,g=rwX,o= ${installdir}/{} \; -cd ${installdir} + -exec cp -Rfv {} "${installdir}" \; \ + -exec chown -R root:_portzap "${installdir}/{}" \; \ + -exec chmod -R u=rwX,g=rwX,o= "${installdir}/{}" \; +cd "${installdir}" for exclude in ${excludes}; do - rm -rf ${exclude} + rm -rf "${exclude}" done diff --git a/libexec/portzap/portzap-pull b/libexec/portzap/portzap-pull index 9dcf4ad..9af285d 100755 --- a/libexec/portzap/portzap-pull +++ b/libexec/portzap/portzap-pull @@ -1,7 +1,7 @@ #!/bin/sh set -ex gitdir=$1 -umask=rwX,g=rwX,o= +umask rwX,g=rwX,o= if [ -e "${gitdir}/.git" ]; then cd "${gitdir}" git pull --rebase origin hardenedbsd/main