Skip to content

Commit 0a1642d

Browse files
committed
Prevent "binary operator expected" error
`test -z` expects a string argument, otherwise, it raises the "binary operator expected" error. The easiest way to convert something to a string is to wrap it in quotes. That's why, in all place, the `test -z` arguments are wrapped with quotes.
1 parent 2812bfb commit 0a1642d

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

libexec/plugins/pipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ branch-pipe() {
5454
# have to add new tests in `git-elegant-release-work.bats` if you want to
5555
# check some specific cases.
5656
local key="elegant.${COMMAND}-current-branch"
57-
if test -z $(--repository-config --get ${key}); then
57+
if test -z "$(--repository-config --get ${key})"; then
5858
--repository-config ${key} $(git rev-parse --abbrev-ref HEAD)
5959
fi
6060

libexec/plugins/state

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ is-there-upstream-for() {
3535
}
3636

3737
are-there-remotes() {
38-
local remotes=$(git remote)
39-
if test -z ${remotes}; then
38+
if test -z "$(git remote)"; then
4039
return 1
4140
fi
4241
return 0

0 commit comments

Comments
 (0)