[PATCH 2/9] dim: use grep -q instead of comparing output
Jani Nikula
jani.nikula at intel.com
Thu Mar 29 08:45:54 UTC 2018
Fixes shellcheck SC2143: Use grep -q instead of comparing output with [
-n .. ].
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
Makefile | 3 +--
dim | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index ad7954b3af96..51e1d42488b0 100644
--- a/Makefile
+++ b/Makefile
@@ -44,8 +44,7 @@ SC_EXCLUDE := \
-e SC2086 \
-e SC2115 \
-e SC2119 \
- -e SC2120 \
- -e SC2143
+ -e SC2120
shellcheck:
shellcheck $(SC_EXCLUDE) dim bash_completion qf
diff --git a/dim b/dim
index c32bbddde6be..2c81907fbdd5 100755
--- a/dim
+++ b/dim
@@ -1228,7 +1228,7 @@ function dim_create_branch
fi
remote=$(repo_to_remote $repo)
- if [[ $(git branch -r | grep "$remote/$branch") ]]; then
+ if git branch -r | grep -q "$remote/$branch"; then
echoerr "$branch already exists on $remote"
return 1
fi
@@ -1423,7 +1423,7 @@ function rangeish()
{
if [ -z "$1" ]; then
echo "HEAD^..HEAD"
- elif [ -n "$(echo $1 | grep '\.\.')" ]; then
+ elif echo "$1" | grep -q '\.\.'; then
echo "$1"
else
echo "$1..HEAD"
--
2.11.0
More information about the dim-tools
mailing list