Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit eb56370

Browse files
CodingMarkusCodingMarkus
CodingMarkus
authored and
CodingMarkus
committed
Simplify syntax
Don't use quotes for test arguments, use '' instead of "" for empty strings and leave out quotes altogether when clearing variables
1 parent e08cf2c commit eb56370

14 files changed

+38
-38
lines changed

lib/psst/basic/print.inc.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ INCLUDE_SEEN_PSST="${INCLUDE_SEEN_PSST-}_print_"
3838
#
3939
print_psst()
4040
(
41-
IFS=""
41+
IFS=
4242
string="$*"
4343

44-
lines=$( printf "%s\n" "$string" \
44+
lines=$( printf "%s\n" "$string" \
4545
| fold -w "$TERM_WIDTH_PSST" -s \
4646
| sed "s/ $//"
4747
)
@@ -78,19 +78,19 @@ print_i_psst()
7878
indent="$1"
7979
shift
8080

81-
IFS=""
81+
IFS=
8282
string="$*"
8383

8484
cols=$(( TERM_WIDTH_PSST - indent ))
8585
lines=$( printf "%s\n" "$string" \
86-
| fold -w "$cols" -s \
86+
| fold -w "$cols" -s \
8787
| sed "s/ $//"
8888
)
8989

9090
IFS="$NL_CHAR_PSST"
9191
for line in $lines
9292
do
9393
line=${line% }
94-
printf "%*s%s\n" "$indent" "" "$line"
94+
printf "%*s%s\n" "$indent" '' "$line"
9595
done
9696
)

lib/psst/file/abspath.inc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ abspath_psst()
4747
return 1
4848
fi
4949

50-
file=""
50+
file=
5151
dir="$path"
5252
if [ ! -d "$dir" ]; then
5353
file=$( basename "$dir" )

lib/psst/file/glob.inc.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ glob_psst()
4343
assert_minargc_psst "$func" 1 $#
4444
assert_hasarg_psst "$func" "filter" "$1"
4545

46-
IFS=""
46+
IFS=
4747
separator=
4848
# shellcheck disable=SC2048 # We need globbing here!
4949
for f in $*
@@ -85,7 +85,7 @@ glob_max_psst()
8585
limit="$1"
8686

8787
shift
88-
IFS=""
88+
IFS=
8989
count=0
9090
separator=
9191
# shellcheck disable=SC2048 # We need globbing here!

test/basic/bin/test_assert.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,52 @@ fi
1818

1919
# Assert fail must always fail
2020
set +e
21-
( assert_fail_psst "test" 2>/dev/null )
21+
( assert_fail_psst test 2>/dev/null )
2222
[ $? = 127 ] || test_fail_psst $LINENO
2323
set -e
2424

2525
# assert_argc must only fail if argument number is wrong
2626
set +e
27-
( assert_argc_psst "test" 3 2 2>/dev/null )
27+
( assert_argc_psst test 3 2 2>/dev/null )
2828
[ $? = 127 ] || test_fail_psst $LINENO
2929

30-
( assert_argc_psst "test" 2 3 2>/dev/null )
30+
( assert_argc_psst test 2 3 2>/dev/null )
3131
[ $? = 127 ] || test_fail_psst $LINENO
3232

33-
( assert_argc_psst "test" 3 3 2>/dev/null ) || test_fail_psst $LINENO
33+
( assert_argc_psst test 3 3 2>/dev/null ) || test_fail_psst $LINENO
3434
set -e
3535

3636
# assert_minargc must only fail if argument number is too low
3737
set +e
38-
( assert_minargc_psst "test" 3 2 2>/dev/null )
38+
( assert_minargc_psst test 3 2 2>/dev/null )
3939
[ $? = 127 ] || test_fail_psst $LINENO
4040

41-
( assert_minargc_psst "test" 2 3 2>/dev/null ) || test_fail_psst $LINENO
41+
( assert_minargc_psst test 2 3 2>/dev/null ) || test_fail_psst $LINENO
4242

43-
( assert_minargc_psst "test" 3 3 2>/dev/null ) || test_fail_psst $LINENO
43+
( assert_minargc_psst test 3 3 2>/dev/null ) || test_fail_psst $LINENO
4444
set -e
4545

4646
# assert_maxargc must only fail if argument number is too high
4747
set +e
48-
( assert_maxargc_psst "test" 3 2 2>/dev/null ) || test_fail_psst $LINENO
48+
( assert_maxargc_psst test 3 2 2>/dev/null ) || test_fail_psst $LINENO
4949

50-
( assert_maxargc_psst "test" 2 3 2>/dev/null )
50+
( assert_maxargc_psst test 2 3 2>/dev/null )
5151
[ $? = 127 ] || test_fail_psst $LINENO
5252

53-
( assert_maxargc_psst "test" 3 3 2>/dev/null ) || test_fail_psst $LINENO
53+
( assert_maxargc_psst test 3 3 2>/dev/null ) || test_fail_psst $LINENO
5454
set -e
5555

5656
# assert_hasarg must fail only if arg is empty
5757
set +e
58-
( assert_hasarg_psst "test" "arg" "x" 2>/dev/null ) || test_fail_psst $LINENO
58+
( assert_hasarg_psst test "arg" "x" 2>/dev/null ) || test_fail_psst $LINENO
5959

60-
( assert_hasarg_psst "test" "arg" "" 2>/dev/null )
60+
( assert_hasarg_psst test "arg" '' 2>/dev/null )
6161
[ $? = 127 ] || test_fail_psst $LINENO
6262

63-
( arg="x" ; assert_hasarg_psst "test" "arg" 2>/dev/null ) \
63+
( arg="x" ; assert_hasarg_psst test "arg" 2>/dev/null ) \
6464
|| test_fail_psst $LINENO
6565

6666
# shellcheck disable=SC2034 # arg is used indirectly by name
67-
( arg="" ; assert_hasarg_psst "test" "arg" 2>/dev/null )
67+
( arg= ; assert_hasarg_psst test "arg" 2>/dev/null )
6868
[ $? = 127 ] || test_fail_psst $LINENO
6969
set -e

test/basic/bin/test_chckcmd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set -e
2727

2828
# Argument must not be empty
2929
set +e
30-
( abspath_psst "" 2>/dev/null )
30+
( abspath_psst '' 2>/dev/null )
3131
[ $? = 127 ] || test_fail_psst $LINENO
3232
set -e
3333

test/basic/bin/test_conv.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set -e
2525

2626
# Argument must not be empty
2727
set +e
28-
( onexit_psst "" 2>/dev/null )
28+
( onexit_psst '' 2>/dev/null )
2929
[ $? = 127 ] || test_fail_psst $LINENO
3030
set -e
3131

@@ -71,7 +71,7 @@ set -e
7171

7272
# Argument must not be empty
7373
set +e
74-
( conv_ord_psst "" 2>/dev/null )
74+
( conv_ord_psst '' 2>/dev/null )
7575
[ $? = 127 ] || test_fail_psst $LINENO
7676
set -e
7777

test/basic/bin/test_esc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ set -e
2828

2929

3030
# Test the encoding
31-
[ "$( esc_for_sq_psst "" )" = "" ] || test_fail_psst $LINENO
31+
[ "$( esc_for_sq_psst '' )" = '' ] || test_fail_psst $LINENO
3232
[ "$( esc_for_sq_psst "abc" )" = "abc" ] || test_fail_psst $LINENO
3333
[ "$( esc_for_sq_psst "ab'cd" )" = "ab'\\''cd" ] || test_fail_psst $LINENO
3434
[ "$( esc_for_sq_psst "'a'b" )" = "'\\''a'\\''b" ] || test_fail_psst $LINENO

test/basic/bin/test_onexit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set -e
2727

2828
# Argument must not be empty
2929
set +e
30-
( onexit_psst "" 2>/dev/null )
30+
( onexit_psst '' 2>/dev/null )
3131
[ $? = 127 ] || test_fail_psst $LINENO
3232
set -e
3333

test/basic/bin/test_perror.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828

2929
# Argument must not be empty
3030
set +e
31-
( perror_i_psst "" 2>/dev/null )
31+
( perror_i_psst '' 2>/dev/null )
3232
[ $? = 127 ] || test_fail_psst $LINENO
3333
set -e
3434
)

test/basic/bin/test_print.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fi
2929

3030
# Argument must not be empty
3131
set +e
32-
( print_i_psst "" 2>/dev/null )
32+
( print_i_psst '' 2>/dev/null )
3333
[ $? = 127 ] || test_fail_psst $LINENO
3434
set -e
3535
)

test/basic/bin/test_stack.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ set -e
2727

2828
# Stack name must not be empty, value can be empty
2929
set +e
30-
( stack_push_psst "test" "" 2>/dev/null )
30+
( stack_push_psst test '' 2>/dev/null )
3131
[ $? = 127 ] || test_fail_psst $LINENO
3232

33-
( stack_push_psst "" "test" 2>/dev/null ) || test_fail_psst $LINENO
33+
( stack_push_psst '' test 2>/dev/null ) || test_fail_psst $LINENO
3434
set -e
3535

3636

@@ -45,10 +45,10 @@ set -e
4545

4646
# Neither one may be empty
4747
set +e
48-
( stack_pop_psst "test" "" 2>/dev/null )
48+
( stack_pop_psst test '' 2>/dev/null )
4949
[ $? = 127 ] || test_fail_psst $LINENO
5050

51-
( stack_pop_psst "" "test" 2>/dev/null )
51+
( stack_pop_psst '' test 2>/dev/null )
5252
[ $? = 127 ] || test_fail_psst $LINENO
5353
set -e
5454

test/basic/bin/test_tmpdir.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set -e
2727

2828
# Argument must not be empty
2929
set +e
30-
( tmpdir_psst "" 2>/dev/null )
30+
( tmpdir_psst '' 2>/dev/null )
3131
[ $? = 127 ] || test_fail_psst $LINENO
3232
set -e
3333

test/file/bin/test_abspath.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set -e
2727

2828
# Argument must not be empty
2929
set +e
30-
( abspath_psst "" 2>/dev/null )
30+
( abspath_psst '' 2>/dev/null )
3131
[ $? = 127 ] || test_fail_psst $LINENO
3232
set -e
3333

test/file/bin/test_glob.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ set -e
2424

2525
# Argument must not be empty
2626
set +e
27-
( glob_psst "" 2>/dev/null )
27+
( glob_psst '' 2>/dev/null )
2828
[ $? = 127 ] || test_fail_psst $LINENO
2929
set -e
3030

@@ -40,10 +40,10 @@ set -e
4040

4141
# Arguments must not be empty
4242
set +e
43-
( glob_max_psst "" 1 2>/dev/null )
43+
( glob_max_psst '' 1 2>/dev/null )
4444
[ $? = 127 ] || test_fail_psst $LINENO
4545

46-
( glob_max_psst 1 "" 2>/dev/null )
46+
( glob_max_psst 1 '' 2>/dev/null )
4747
[ $? = 127 ] || test_fail_psst $LINENO
4848
set -e
4949

0 commit comments

Comments
 (0)