Skip to content

Commit 807117c

Browse files
committed
bin/check-warn.sh: prefer test conditionals
Prefer test conditionals over bash conditionals where applicable. Signed-off-by: Randolph Sapp <[email protected]>
1 parent cabde74 commit 807117c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

bin/check-warn.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ usage()
3131

3232
restore_branch()
3333
{
34-
[[ -z "$_cbr" ]] || git checkout "$_cbr"
34+
[ -z "$_cbr" ] || git checkout "$_cbr"
3535
}
3636

3737
### main() ###
@@ -47,9 +47,11 @@ while [ "$#" -gt 0 ]; do
4747
esac
4848
done
4949

50-
[[ -n "$_dev" ]] || usage 1
51-
[[ -n "$_old" && -n "$_new" ]] || usage 2
52-
[[ -n "$_os" ]] || _os=linux
50+
[ -n "$_dev" ] || usage 1
51+
if [ -z "$_old" ] || [ -z "$_new" ]; then
52+
usage 2
53+
fi
54+
[ -n "$_os" ] || _os=linux
5355

5456
if [[ "$(head -1 Makefile 2> /dev/null)" != "# Makefile for Sphinx"* ]]
5557
then
@@ -58,7 +60,7 @@ then
5860
fi
5961

6062
# do nothing if current workspace is not clean
61-
if [[ -n "$(git status --porcelain --untracked-files=no)" ]]
63+
if [ -n "$(git status --porcelain --untracked-files=no)" ]
6264
then
6365
echo "Error: Current workspace has uncommitted changes"
6466
exit 4
@@ -72,17 +74,17 @@ if ! git cat-file -t "${_new}" > /dev/null 2>&1; then
7274
fi
7375

7476
# convert 'HEAD' to its commit ID
75-
if [[ "$_new" == "HEAD" ]]; then
77+
if [ "$_new" = "HEAD" ]; then
7678
_new=$(git rev-parse HEAD)
7779
fi
78-
if [[ "$_old" == "HEAD" ]]; then
80+
if [ "$_old" = "HEAD" ]; then
7981
_old=$(git rev-parse HEAD)
8082
fi
8183

8284

8385
# get current branch name or commit ID
8486
_cbr=$(git branch | sed -n '/\* /s///p')
85-
if [[ $_cbr == "(HEAD detached"* ]]; then
87+
if [[ "$_cbr" == "(HEAD detached"* ]]; then
8688
_cbr=$(git rev-parse HEAD)
8789
fi
8890

@@ -113,7 +115,7 @@ echo
113115
echo "Found $_num new build WARNING(s)."
114116
echo
115117

116-
if [[ $_num != "0" ]]; then
118+
if [ "$_num" != "0" ]; then
117119
cat build/_new-warn.log
118120
fi
119121

0 commit comments

Comments
 (0)