Skip to content

Commit

Permalink
Use hard quotes in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
thevindu-w committed Feb 28, 2025
1 parent 4b4eaf7 commit 0a0c4ef
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
36 changes: 18 additions & 18 deletions helper_tools/install-online-linux-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error_exit() {
exit 1
}

shopt -s expand_aliases 2>/dev/null || error_exit "Please run using bash"
shopt -s expand_aliases 2>/dev/null || error_exit 'Please run using bash'
set -e

if [ "$(id -u)" = 0 ]; then
Expand All @@ -30,23 +30,23 @@ require_tool() {

OS="$(uname 2>/dev/null || echo Unknown)"

if [ "$OS" = "Linux" ]; then
if [ "$OS" = 'Linux' ]; then
if ! type tar &>/dev/null; then
export PATH="/usr/bin:$PATH"
fi
require_tool tar
alias extract='tar -xzf'
installer="install-linux.sh"
elif [ "$OS" = "Darwin" ]; then
installer='install-linux.sh'
elif [ "$OS" = 'Darwin' ]; then
if ! type unzip &>/dev/null; then
export PATH="/usr/bin:$PATH"
fi
require_tool unzip
alias extract='unzip'
installer="install-mac.sh"
installer='install-mac.sh'
else
echo "This installer supports Linux and macOS only."
error_exit "Installation failed!"
echo 'This installer supports Linux and macOS only.'
error_exit 'Installation failed!'
fi

if ! type curl &>/dev/null; then
Expand All @@ -68,7 +68,7 @@ VERSION_DEFAULT=
if [ -z "$VERSION_DEFAULT" ]; then
read -p 'Enter version (ex: 3.2.0): ' VERSION_DEFAULT
fi
VERSION="$(echo -n "${VERSION_DEFAULT}" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" || error_exit "Invalid version"
VERSION="$(echo -n "${VERSION_DEFAULT}" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" || error_exit 'Invalid version'

echo "You are installing ClipShare version $VERSION"
read -p 'Proceed? [y/N] ' confirm
Expand All @@ -78,22 +78,22 @@ if [ "${confirm::1}" != 'y' ] && [ "${confirm::1}" != 'Y' ]; then
fi

filename_prefix="clip_share_server-$VERSION"
if [ "$OS" = "Linux" ]; then
if [ "$OS" = 'Linux' ]; then
filename="${filename_prefix}-linux_x86_64.tar.gz"
elif [ "$OS" = "Darwin" ]; then
elif [ "$OS" = 'Darwin' ]; then
filename="${filename_prefix}-macos.zip"
fi

url="https://github.com/thevindu-w/clip_share_server/releases/download/v${VERSION}/${filename}"

suffix=0
tmpdir="clipsharetmp"
tmpdir='clipsharetmp'
while [ -e "$tmpdir" ]; do
[ "$suffix" -gt "1000" ] && error_exit "Creating temporary directory failed"
[ "$suffix" -gt "1000" ] && error_exit 'Creating temporary directory failed'
suffix="$((suffix + 1))"
tmpdir="clipsharetmp_$suffix"
done
mkdir "$tmpdir" &>/dev/null || error_exit "Creating temporary directory failed"
mkdir "$tmpdir" &>/dev/null || error_exit 'Creating temporary directory failed'
cd "$tmpdir"

cleanup() {
Expand All @@ -104,29 +104,29 @@ cleanup() {
echo -n 'Downloading binaries ...'
if ! download "$url" &>/dev/null; then
cleanup
error_exit "Download failed"
error_exit 'Download failed'
fi
echo -e '\rDownload completed '

echo -n 'Extracting ...'
if ! extract "$filename" &>/dev/null; then
cleanup
error_exit "Extraction failed"
error_exit 'Extraction failed'
fi
echo -e '\rExtracting completed '

if [ ! -f "$installer" ]; then
cd "$filename_prefix"*/ || (
cleanup
error_exit "Cannot find installer for this operating system"
error_exit 'Cannot find installer for this operating system'
)
fi
if [ ! -f "$installer" ]; then
cleanup
error_exit "Cannot find installer for this operating system"
error_exit 'Cannot find installer for this operating system'
fi

chmod +x "$installer"
"./$installer" || error_exit "Installation failed"
"./$installer" || error_exit 'Installation failed'

cleanup
2 changes: 1 addition & 1 deletion tests/scripts/common/get_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ elif [ "$DETECTED_OS" = 'macOS' ]; then
exit 1
fi
else
showStatus info "Unknown OS."
showStatus info 'Unknown OS.'
exit 1
fi
4 changes: 2 additions & 2 deletions tests/scripts/common/x.2.1_send_text.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

. init.sh

sample="send_text 範例文字 1"
sample='send_text 範例文字 1'

method="$METHOD_SEND_TEXT"
printf -v _ '%s%n' "$sample" utf8len
Expand All @@ -28,7 +28,7 @@ fi
clip="$(get_copied_text || echo fail)"

if [ "$clip" != "$sampleDump" ]; then
showStatus info "Clipcoard content not matching."
showStatus info 'Clipcoard content not matching.'
echo 'Expected:' "$sampleDump"
echo 'Received:' "$clip"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/conf_method_enabled.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ SEND_TEXT_STATUS="$METHOD_OK"
SEND_FILES_STATUS="$METHOD_OK"
INFO_STATUS="$METHOD_OK"

TEXT="0000000000000000"
FILE_CNT="0000000000000000"
TEXT='0000000000000000'
FILE_CNT='0000000000000000'

check_all_methods() {
check_method "$METHOD_GET_TEXT" "$GET_TEXT_STATUS"
Expand Down

0 comments on commit 0a0c4ef

Please sign in to comment.