Skip to content

Commit b82d532

Browse files
committed
refactor: fix shellcheck issues
1 parent 1c672bb commit b82d532

File tree

9 files changed

+26
-28
lines changed

9 files changed

+26
-28
lines changed

bin/ap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ usage() {
7878

7979
# NOTE: $'foo' is the escape sequence syntax of bash
8080
local nl=$'\n' # new line
81-
(($# > 0)) && redPrint "$*$nl" >$out
81+
(($# > 0)) && redPrint "$*$nl" >"$out"
8282

83-
cat >$out <<EOF
83+
cat >"$out" <<EOF
8484
Usage: ${PROG} [OPTION]... [FILE]...
8585
convert to Absolute Path.
8686

bin/c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ usage() {
5151
# shellcheck disable=SC2015
5252
[ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout
5353

54-
(($# > 0)) && printErrorMsg "$*" >$out
54+
(($# > 0)) && printErrorMsg "$*" >"$out"
5555

56-
cat >$out <<EOF
56+
cat >"$out" <<EOF
5757
Usage: ${PROG} [OPTION]... [command [command_args ...]]
5858
Run command and put output to system clipper.
5959
If no command is specified, read from stdin(pipe).

bin/cp-into-docker-run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ usage() {
7171

7272
# NOTE: $'foo' is the escape sequence syntax of bash
7373
local nl=$'\n' # new line
74-
(($# > 0)) && redPrint "$*$nl" >$out
74+
(($# > 0)) && redPrint "$*$nl" >"$out"
7575

76-
cat >$out <<EOF
76+
cat >"$out" <<EOF
7777
Usage: ${PROG} [OPTION]... command [command-args]...
7878
7979
Copy the command into docker container

bin/find-in-jars

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ usage() {
100100

101101
# NOTE: $'foo' is the escape sequence syntax of bash
102102
local -r nl=$'\n' # new line
103-
(($# > 0)) && redPrint "$*$nl" >$out
103+
(($# > 0)) && redPrint "$*$nl" >"$out"
104104

105-
cat >$out <<EOF
105+
cat >"$out" <<EOF
106106
Usage: ${PROG} [OPTION]... PATTERN
107107
108108
Find files in the jar files under specified directory,
@@ -376,7 +376,7 @@ __outputResultOfJarFile() {
376376
matched=true
377377
fi
378378

379-
if [ $print_matched_files != $matched ]; then
379+
if [ "$print_matched_files" != "$matched" ]; then
380380
return
381381
fi
382382

bin/rp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ usage() {
7676

7777
# NOTE: $'foo' is the escape sequence syntax of bash
7878
local nl=$'\n' # new line
79-
(($# > 0)) && redPrint "$*$nl" >$out
79+
(($# > 0)) && redPrint "$*$nl" >"$out"
8080

81-
cat >$out <<EOF
81+
cat >"$out" <<EOF
8282
Usage: ${PROG} [OPTION]... [FILE]...
8383
convert to Relative Path.
8484

bin/show-busy-java-threads

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ readonly USER
4949
################################################################################
5050

5151
# NOTE: $'foo' is the escape sequence syntax of bash
52-
readonly ec=$'\033' # escape char
53-
readonly eend=$'\033[0m' # escape end
54-
readonly nl=$'\n' # new line
52+
readonly nl=$'\n' # new line
5553

5654
colorPrint() {
5755
local color=$1
@@ -154,9 +152,9 @@ usage() {
154152
# shellcheck disable=SC2015
155153
[ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout
156154

157-
(($# > 0)) && colorPrint 31 "$*$nl" >$out
155+
(($# > 0)) && colorPrint 31 "$*$nl" >"$out"
158156

159-
cat >$out <<EOF
157+
cat >"$out" <<EOF
160158
Usage: ${PROG} [OPTION]... [delay [count]]
161159
Find out the highest cpu consumed threads of java processes,
162160
and print the stack of these threads.

bin/uq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ usage() {
9090
# shellcheck disable=SC2015
9191
[ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout
9292

93-
(($# > 0)) && redPrint "$*$nl" >$out
93+
(($# > 0)) && redPrint "$*$nl" >"$out"
9494

95-
cat >$out <<EOF
95+
cat >"$out" <<EOF
9696
Usage: ${PROG} [OPTION]... [INPUT [OUTPUT]]
9797
Filter lines from INPUT (or standard input), writing to OUTPUT (or standard output).
9898
Same as \`uniq\` command in core utils,

bin/xpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ usage() {
4040
# shellcheck disable=SC2015
4141
[ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout
4242

43-
(($# > 0)) && printf '%s\n\n' "$*" >$out
43+
(($# > 0)) && printf '%s\n\n' "$*" >"$out"
4444

4545
cat <<EOF
4646
Usage: ${PROG} [OPTION] [FILE]...

lib/console-text-color-themes.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ colorEchoWithoutNewLine() {
7272

7373
echo 'Code sample to print color text:'
7474

75-
echo -n ' echo -e "\033['
75+
printf %s ' echo -e "\033['
7676
colorEchoWithoutNewLine '3;35;40' '1;36;41'
77-
echo -n m
77+
printf %s m
7878
colorEchoWithoutNewLine '0;32;40' 'Sample Text'
79-
echo '\033[0m"'
79+
printf '%s\n' '\033[0m"'
8080

81-
echo -n " echo \$'\033["
81+
printf %s " echo \$'\033["
8282
colorEchoWithoutNewLine '3;35;40' '1;36;41'
83-
echo -n "m'\""
83+
printf %s "m'\""
8484
colorEchoWithoutNewLine '0;32;40' 'Sample Text'
85-
echo "\"$'\033[0m'"
86-
echo " # NOTE: $'foo' is the escape sequence syntax of bash, safer escape"
85+
printf '%s\n' "\"$'\033[0m'"
86+
printf '%s\n' " # NOTE: $'foo' is the escape sequence syntax of bash, safer escape"
8787

88-
echo 'Output of above code:'
89-
echo -n ' '
88+
printf '%s\n' 'Output of above code:'
89+
printf %s ' '
9090
colorEcho '1;36;41' 'Sample Text'
9191
echo
9292
echo 'If you are going crazy to write text in escapes string like me,'

0 commit comments

Comments
 (0)