Skip to content

Commit d35bed5

Browse files
optizonexarkes
authored andcommittedMay 15, 2019
Shellcheck on build.sh (rizinorg#1534)
1 parent 2ba9e17 commit d35bed5

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed
 

‎build.sh

+21-20
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
ERR=0
77

88
#### User variables ####
9-
BUILD="`pwd`/build"
9+
BUILD="$(pwd)/build"
1010
QMAKE_CONF=$*
11-
ROOT_DIR=`pwd`
11+
ROOT_DIR=$(pwd)
1212

1313
check_r2() {
1414
r2 -v >/dev/null 2>&1
@@ -23,9 +23,9 @@ check_r2() {
2323
}
2424

2525
find_qmake() {
26-
qmakepath=$(which qmake-qt5)
26+
qmakepath=$(command -v qmake-qt5)
2727
if [ -z "$qmakepath" ]; then
28-
qmakepath=$(which qmake)
28+
qmakepath=$(command -v qmake)
2929
fi
3030
if [ -z "$qmakepath" ]; then
3131
echo "You need qmake to build Cutter."
@@ -36,9 +36,9 @@ find_qmake() {
3636
}
3737

3838
find_lrelease() {
39-
lreleasepath=$(which lrelease-qt5)
39+
lreleasepath=$(command -v lrelease-qt5)
4040
if [ -z "$lreleasepath" ]; then
41-
lreleasepath=$(which lrelease)
41+
lreleasepath=$(command -v lrelease)
4242
fi
4343
if [ -z "$lreleasepath" ]; then
4444
echo "You need lrelease to build Cutter."
@@ -49,9 +49,9 @@ find_lrelease() {
4949
}
5050

5151
find_gmake() {
52-
gmakepath=$(which gmake)
52+
gmakepath=$(command -v gmake)
5353
if [ -z "$gmakepath" ]; then
54-
gmakepath=$(which make)
54+
gmakepath=$(command -v make)
5555
fi
5656

5757
${gmakepath} --help 2>&1 | grep -q gnu
@@ -64,15 +64,16 @@ find_gmake() {
6464
}
6565

6666
prepare_breakpad() {
67-
if [ -z $OSTYPE ]; then
67+
OS="$(uname -s)"
68+
if [ -z "$OS" ]; then
6869
echo "Could not identify OS, OSTYPE var is empty. You can try to disable breakpad to avoid this error."
6970
exit 1
7071
fi
7172

72-
if [ $OSTYPE = "linux-gnu" ]; then
73+
if [ "$OS" = "Linux" ]; then
7374
. $ROOT_DIR/scripts/prepare_breakpad_linux.sh
7475
export PKG_CONFIG_PATH="$CUSTOM_BREAKPAD_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
75-
elif [ $OSTYPE = "darwin" ]; then
76+
elif [ "$OS" = "Darwin" ]; then
7677
. $ROOT_DIR/scripts/prepare_breakpad_macos.sh
7778
fi
7879
}
@@ -81,8 +82,8 @@ prepare_breakpad() {
8182
check_r2
8283
if [ $? -eq 1 ]; then
8384
printf "A (new?) version of radare2 will be installed. Do you agree? [Y/n] "
84-
read answer
85-
if [ -z "$answer" -o "$answer" = "Y" -o "$answer" = "y" ]; then
85+
read -r answer
86+
if [ -z "$answer" ] || [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then
8687
R2PREFIX=${1:-"/usr"}
8788
git submodule init && git submodule update
8889
cd radare2 || exit 1
@@ -100,19 +101,19 @@ fi
100101
$(find_lrelease) ./src/Cutter.pro
101102

102103
# Build
103-
if [ "${QMAKE_CONF/CUTTER_ENABLE_CRASH_REPORTS=true/something}" != $QMAKE_CONF ]; then
104+
if [ "${QMAKE_CONF#*CUTTER_ENABLE_CRASH_REPORTS=true}" != "$QMAKE_CONF" ]; then
104105
prepare_breakpad
105106
fi
106107
mkdir -p "$BUILD"
107108
cd "$BUILD" || exit 1
108-
$(find_qmake) ../src/Cutter.pro $QMAKE_CONF
109+
$(find_qmake) ../src/Cutter.pro "$QMAKE_CONF"
109110
$(find_gmake) -j4
110111
ERR=$((ERR+$?))
111112

112113
# Move translations
113-
mkdir -p "`pwd`/translations"
114-
find "$ROOT_DIR/src/translations" -maxdepth 1 -type f | grep "cutter_..\.qm" | while read SRC_FILE; do
115-
mv $SRC_FILE "`pwd`/translations"
114+
mkdir -p "$(pwd)/translations"
115+
find "$ROOT_DIR/src/translations" -maxdepth 1 -type f | grep "cutter_..\.qm" | while read -r SRC_FILE; do
116+
mv "$SRC_FILE" "$(pwd)/translations"
116117
done
117118

118119
# Finish
@@ -121,8 +122,8 @@ if [ ${ERR} -gt 0 ]; then
121122
else
122123
echo "Build complete."
123124
printf "This build of Cutter will be installed. Do you agree? [Y/n] "
124-
read answer
125-
if [ -z "$answer" -o "$answer" = "Y" -o "$answer" = "y" ]; then
125+
read -r answer
126+
if [ -z "$answer" ] || [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then
126127
$(find_gmake) install
127128
else
128129
echo "Binary available at $BUILD/Cutter"

0 commit comments

Comments
 (0)
Please sign in to comment.