Skip to content

Commit c17f11f

Browse files
committed
Merge #10773: Shell script cleanups
13a81b1 Add quotes to variable assignment (as requested by @TheBlueMatt) (practicalswift) 683b9d2 Fix valid path output (practicalswift) 193c2fb Use bash instead of POSIX sh. POSIX sh does not support arrays. (practicalswift) 80f5f28 Fix incorrect quoting of quotes (the previous quotes had no effect beyond unquoting) (practicalswift) 564a172 Add required space to [[ -n "$1" ]] (previously [[ -n"$1" ]]) (practicalswift) 1e44ae0 Add error handling: exit if cd fails (practicalswift) b9e79ab Remove "\n" from echo argument. echo does not support escape sequences. (practicalswift) f6b3382 Remove unused variables (practicalswift) Pull request description: Shell script cleanups: * Add required space to `[ -n ]`. * Avoid quote within quote. * Exit if `cd` fails. * Remove `\n` which is not handled by `echo`. * ~~Remove redundant `$` in arithmetic variable expression.~~ * ~~Use `$(command)` instead of legacy form `` `command` ``.~~ * Arrays are not supported in POSIX `sh`. Use `bash` when arrays are used. * ~~`[ foo -a bar ]` is not well defined, use `[ foo ] && [ bar ]` instead.~~ * ~~`[ foo -o bar ]` is not well defined, use `[ foo ] || [ bar ]` instead.~~ Tree-SHA512: 80f6ded58bce625b15b4da30d69d2714c633e184e62b21ed67d2c58e2ebaa08b4147593324012694d02bf4f1f252844cdff2fd1cf5e817ddb07e2777db7a6390
2 parents 24df9af + 13a81b1 commit c17f11f

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

contrib/devtools/gen-manpages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
44
SRCDIR=${SRCDIR:-$TOPDIR/src}

contrib/gitian-build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ while :; do
105105
fi
106106
shift
107107
else
108-
echo 'Error: "--os" requires an argument containing an l (for linux), w (for windows), or x (for Mac OSX)\n'
108+
echo 'Error: "--os" requires an argument containing an l (for linux), w (for windows), or x (for Mac OSX)'
109109
exit 1
110110
fi
111111
;;
@@ -188,7 +188,7 @@ then
188188
fi
189189

190190
# Get signer
191-
if [[ -n"$1" ]]
191+
if [[ -n "$1" ]]
192192
then
193193
SIGNER=$1
194194
shift

contrib/macdeploy/detached-sig-create.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ grep CodeResources < "${TEMPLIST}" | while read i; do
4040
RESOURCE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}"
4141
DIRNAME="`dirname "${RESOURCE}"`"
4242
mkdir -p "${DIRNAME}"
43-
echo "Adding resource for: "${TARGETFILE}""
43+
echo "Adding resource for: \"${TARGETFILE}\""
4444
cp "${i}" "${RESOURCE}"
4545
done
4646

contrib/tidy_datadir.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
if [ -d "$1" ]; then
7-
cd "$1"
7+
cd "$1" || exit 1
88
else
99
echo "Usage: $0 <datadir>" >&2
1010
echo "Removes obsolete Bitcoin database files" >&2

contrib/verify-commits/verify-commits.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ fi
3333

3434
NO_SHA1=1
3535
PREV_COMMIT=""
36+
INITIAL_COMMIT="${CURRENT_COMMIT}"
3637

3738
while true; do
3839
if [ "$CURRENT_COMMIT" = $VERIFIED_ROOT ]; then
39-
echo "There is a valid path from "$CURRENT_COMMIT" to $VERIFIED_ROOT where all commits are signed!"
40+
echo "There is a valid path from \"$INITIAL_COMMIT\" to $VERIFIED_ROOT where all commits are signed!"
4041
exit 0
4142
fi
4243

contrib/verifybinaries/verify.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if [ ! -d "$WORKINGDIR" ]; then
3333
mkdir "$WORKINGDIR"
3434
fi
3535

36-
cd "$WORKINGDIR"
36+
cd "$WORKINGDIR" || exit 1
3737

3838
#test if a version number has been passed as an argument
3939
if [ -n "$1" ]; then
@@ -87,7 +87,7 @@ WGETOUT=$(wget -N "$HOST1$BASEDIR$SIGNATUREFILENAME" 2>&1)
8787
#and then see if wget completed successfully
8888
if [ $? -ne 0 ]; then
8989
echo "Error: couldn't fetch signature file. Have you specified the version number in the following format?"
90-
echo "[$VERSIONPREFIX]<version>-[$RCVERSIONSTRING[0-9]] (example: "$VERSIONPREFIX"0.10.4-"$RCVERSIONSTRING"1)"
90+
echo "[$VERSIONPREFIX]<version>-[$RCVERSIONSTRING[0-9]] (example: ${VERSIONPREFIX}0.10.4-${RCVERSIONSTRING}1)"
9191
echo "wget output:"
9292
echo "$WGETOUT"|sed 's/^/\t/g'
9393
exit 2

share/genbuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
if [ $# -gt 1 ]; then
7-
cd "$2"
7+
cd "$2" || exit 1
88
fi
99
if [ $# -gt 0 ]; then
1010
FILE="$1"

0 commit comments

Comments
 (0)