Fix shellcheck warnings

This commit is contained in:
a1346054 2021-09-22 21:46:52 +00:00
parent 9bb25d8887
commit 486545527b
No known key found for this signature in database
GPG Key ID: D149AD21DC40440C
6 changed files with 36 additions and 36 deletions

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
cd "$(dirname $0)" || exit 1 cd "$(dirname "$0")" || exit 1
# some environments have cmake v2 as 'cmake' and v3 as 'cmake3' # some environments have cmake v2 as 'cmake' and v3 as 'cmake3'
# check for cmake3 first then fallback to just cmake # check for cmake3 first then fallback to just cmake
B_CMAKE=`type cmake3 2>/dev/null` B_CMAKE=`type cmake3 2>/dev/null`
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
B_CMAKE=`echo $B_CMAKE | cut -d' ' -f3` B_CMAKE=`echo "$B_CMAKE" | cut -d' ' -f3`
else else
B_CMAKE=cmake B_CMAKE=cmake
fi fi
@ -26,7 +26,7 @@ B_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=$B_BUILD_TYPE $B_CMAKE_FLAGS"
rm -rf build rm -rf build
mkdir build || exit 1 mkdir build || exit 1
cd build || exit 1 cd build || exit 1
echo Starting Barrier $B_BUILD_TYPE build... echo "Starting Barrier $B_BUILD_TYPE build..."
$B_CMAKE $B_CMAKE_FLAGS .. || exit 1 $B_CMAKE $B_CMAKE_FLAGS .. || exit 1
make || exit 1 make || exit 1
echo "Build completed successfully" echo "Build completed successfully"

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Use the same verbose variable as CMake # Use the same verbose variable as CMake
[ "$VERBOSE" == "1" ] && set -x [ "$VERBOSE" = "1" ] && set -x
# Exit on unset variables or pipe errors # Exit on unset variables or pipe errors
set -uo pipefail set -uo pipefail
@ -14,10 +14,10 @@ B_BARRIERC="Barrier.app/Contents/MacOS/barrierc"
B_BARRIERS="Barrier.app/Contents/MacOS/barriers" B_BARRIERS="Barrier.app/Contents/MacOS/barriers"
# Colorized output # Colorized output
function info() { tput bold; echo "$@" ; tput sgr0 ;} info() { tput bold; echo "$@"; tput sgr0 ; }
function error() { tput bold; tput setaf 1; echo "$@"; tput sgr0 ; } error() { tput bold; tput setaf 1; echo "$@"; tput sgr0 ; }
function success() { tput bold; tput setaf 2; echo "$@"; tput sgr0 ; } success() { tput bold; tput setaf 2; echo "$@"; tput sgr0 ; }
function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; } warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
info "Checking for bundle contents" info "Checking for bundle contents"
if [ ! -d "Barrier.app/Contents" ]; then if [ ! -d "Barrier.app/Contents" ]; then
@ -40,7 +40,7 @@ if which -s port ; then
info "MacPorts found, searching for macdeployqt" info "MacPorts found, searching for macdeployqt"
DEPLOYQT="$(port contents qt5-qttools | grep --only --max-count 1 '/.*macdeployqt')" DEPLOYQT="$(port contents qt5-qttools | grep --only --max-count 1 '/.*macdeployqt')"
if [ ! -x "$DEPLOYQT" ]; then if [ ! -x "$DEPLOYQT" ]; then
error Please install package qt5-qttools error "Please install package qt5-qttools"
exit 1 exit 1
fi fi
fi fi
@ -50,13 +50,13 @@ if which -s brew ; then
info "Homebrew found, searching for macdeployqt" info "Homebrew found, searching for macdeployqt"
DEPLOYQT="$(brew list qt@5 | grep --only '/.*macdeployqt' | head -1)" DEPLOYQT="$(brew list qt@5 | grep --only '/.*macdeployqt' | head -1)"
if [ ! -x "$DEPLOYQT" ]; then if [ ! -x "$DEPLOYQT" ]; then
error Please install package qt error "Please install package qt"
exit 1 exit 1
fi fi
fi fi
# Use macdeployqt to include libraries and create dmg # Use macdeployqt to include libraries and create dmg
if [ "$B_BUILDTYPE" == "Release" ]; then if [ "$B_BUILDTYPE" = "Release" ]; then
info "Building Release disk image (dmg)" info "Building Release disk image (dmg)"
"$DEPLOYQT" Barrier.app -dmg \ "$DEPLOYQT" Barrier.app -dmg \
-executable="$B_BARRIERC" \ -executable="$B_BARRIERC" \

View File

@ -1,30 +1,30 @@
#!/bin/sh #!/bin/sh
# add warning for users running manually # add warning for users running manually
function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; } warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated." warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated."
warn "Please use build_dist.sh instead to deploy using macdeployqt" warn "Please use build_dist.sh instead to deploy using macdeployqt"
# change this to rename the installer package # change this to rename the installer package
B_DMG="Barrier-@BARRIER_VERSION@.dmg" B_DMG="Barrier-@BARRIER_VERSION@.dmg"
cd "$( dirname '$0' )" cd "$( dirname "$0" )"
OWNDIR="$( pwd )" OWNDIR="$( pwd )"
B_REREF_SCRIPT="$OWNDIR/reref_dylibs.sh" B_REREF_SCRIPT="$OWNDIR/reref_dylibs.sh"
if [ ! -x $B_REREF_SCRIPT ]; then if [ ! -x "$B_REREF_SCRIPT" ]; then
echo Missing script: $B_REREF_SCRIPT echo "Missing script: $B_REREF_SCRIPT"
exit 1 exit 1
fi fi
# remove any old copies so there's no confusion about whether this # remove any old copies so there's no confusion about whether this
# process completes successfully or not # process completes successfully or not
rm -rf temp.dmg $B_DMG rm -rf temp.dmg "$B_DMG"
cd Barrier.app/Contents 2>/dev/null cd Barrier.app/Contents 2>/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo Please make sure that the build completed successfully echo "Please make sure that the build completed successfully"
echo before trying to create the installer. echo "before trying to create the installer."
exit 1 exit 1
fi fi
@ -77,7 +77,7 @@ hdiutil create -size 64m -fs HFS+ -volname "Barrier" temp.dmg || exit 1
hdiutil attach temp.dmg -mountpoint mnt || exit 1 hdiutil attach temp.dmg -mountpoint mnt || exit 1
cp -r Barrier.app mnt/ || exit 1 cp -r Barrier.app mnt/ || exit 1
hdiutil detach mnt || exit 1 hdiutil detach mnt || exit 1
hdiutil convert temp.dmg -format UDZO -o $B_DMG || exit 1 hdiutil convert temp.dmg -format UDZO -o "$B_DMG" || exit 1
rm temp.dmg rm temp.dmg
echo "dmg $B_DMB created successfully" echo "dmg $B_DMG created successfully"

View File

@ -5,28 +5,28 @@ B_TARGET=$1
if [ "x$B_TARGET" = "x" ]; then if [ "x$B_TARGET" = "x" ]; then
# add warning for users running manually # add warning for users running manually
function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; } warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated." warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated."
warn "Please use build_dist.sh instead to deploy using macdeployqt" warn "Please use build_dist.sh instead to deploy using macdeployqt"
echo Which binary needs to be re-referenced? echo "Which binary needs to be re-referenced?"
exit 1 exit 1
fi fi
cd $(dirname $B_TARGET) || exit 1 cd "$(dirname "$B_TARGET")" || exit 1
# where to find non-system libraries relative to target's directory. # where to find non-system libraries relative to target's directory.
# the vast majority of the time this should be empty # the vast majority of the time this should be empty
B_REL_PATH=$2 B_REL_PATH=$2
# we're in target's directory now. trim off the path # we're in target's directory now. trim off the path
B_TARGET=$(basename $B_TARGET) B_TARGET=$(basename "$B_TARGET")
# get a list of non-system libraries and make local copies # get a list of non-system libraries and make local copies
B_LIBS=$(otool -XL $B_TARGET | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)') B_LIBS=$(otool -XL "$B_TARGET" | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)')
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && exit 1
for B_LIB in $B_LIBS; do for B_LIB in $B_LIBS; do
B_LIB_NAME=$(basename $B_LIB) B_LIB_NAME=$(basename "$B_LIB")
# otool reports barrier as "barrier:" which fails self-reference test below # otool reports barrier as "barrier:" which fails self-reference test below
B_LIB_NAME=${B_LIB_NAME//:} B_LIB_NAME=${B_LIB_NAME//:}
@ -34,16 +34,16 @@ for B_LIB in $B_LIBS; do
[ "$B_TARGET" = "$B_LIB_NAME" ] && continue [ "$B_TARGET" = "$B_LIB_NAME" ] && continue
B_DST=${B_REL_PATH}${B_LIB_NAME} B_DST=${B_REL_PATH}${B_LIB_NAME}
if [ ! -e $B_DST ]; then if [ ! -e "$B_DST" ]; then
cp $B_LIB $B_DST || exit 1 cp "$B_LIB" "$B_DST" || exit 1
chmod u+rw $B_DST || exit 1 chmod u+rw "$B_DST" || exit 1
# recursively call this script on libraries purposefully not passing # recursively call this script on libraries purposefully not passing
# $B_REL_PATH so that it is only used explicitly # $B_REL_PATH so that it is only used explicitly
$0 $B_DST $0 "$B_DST"
fi fi
# adjust the target's metadata to point to the local copy # adjust the target's metadata to point to the local copy
# rather than the system-wide copy which would only exist on # rather than the system-wide copy which would only exist on
# a development machine # a development machine
install_name_tool -change $B_LIB @loader_path/$B_DST $B_TARGET || exit 1 install_name_tool -change "$B_LIB" "@loader_path/$B_DST" "$B_TARGET" || exit 1
done done

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Checks if directory exists, otherwise asks to install package. # Checks if directory exists, otherwise asks to install package.
function check_dir_exists() { check_dir_exists() {
local path=$1 local path=$1
local package=$2 local package=$2
@ -11,7 +11,7 @@ function check_dir_exists() {
fi fi
} }
if [ ! $BARRIER_BUILD_ENV ]; then if [ -z "$BARRIER_BUILD_ENV" ]; then
check_dir_exists '/Applications/Xcode.app' 'Xcode' check_dir_exists '/Applications/Xcode.app' 'Xcode'
printf "Modifying environment for Barrier build...\n" printf "Modifying environment for Barrier build...\n"

View File

@ -4,7 +4,7 @@ if ! which magick >/dev/null 2>&1; then
echo "Need ImageMagic for this" echo "Need ImageMagic for this"
exit 10 exit 10
fi fi
cd $(dirname $0) || exit $? cd "$(dirname "$0")" || exit $?
if [ ! -r barrier.png ]; then if [ ! -r barrier.png ]; then
echo "Use inkscape (or another vector graphics editor) to create barrier.png from barrier.svg first" echo "Use inkscape (or another vector graphics editor) to create barrier.png from barrier.svg first"
exit 10 exit 10
@ -12,11 +12,11 @@ fi
rm -rf work || exit $? rm -rf work || exit $?
mkdir -p work || exit $? mkdir -p work || exit $?
for s in 16 24 32 48 64 128 256 512 1024; do for s in 16 24 32 48 64 128 256 512 1024; do
magick convert barrier.png -resize ${s}x${s} -depth 8 work/${s}.png || exit $? magick convert barrier.png -resize "${s}x${s}" -depth 8 "work/${s}.png" || exit $?
done done
# windows icon # windows icon
magick convert work/{16,24,32,48,64,128}.png barrier.png barrier.ico || exit $? magick convert work/{16,24,32,48,64,128}.png barrier.png barrier.ico || exit $?
# macos icon # macos icon
png2icns $ICNS_BASE/Barrier.icns work/{16,32,256,512,1024}.png || exit $? png2icns "$ICNS_BASE/Barrier.icns" work/{16,32,256,512,1024}.png || exit $?
rm -rf work rm -rf work
echo Done echo Done