Skip to content

Commit

Permalink
Switch grep -q for >/dev/null
Browse files Browse the repository at this point in the history
This makes the grep commands cross-platform compatible.
  • Loading branch information
lildude committed Dec 12, 2014
1 parent a826aca commit f7c15c5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bin/ghe-host-check
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set -e
if [ $rc -ne 0 ]; then
case $rc in
255)
if echo "$output" | grep -i -q "port 22: connection refused"; then
if echo "$output" | grep -i "port 22: connection refused" >/dev/null; then
exec "$0" "$hostname:122"
fi

Expand All @@ -44,7 +44,7 @@ if [ $rc -ne 0 ]; then
echo "Error: couldn't read GitHub Enterprise fingerprint on '$host' or this isn't a GitHub appliance." 1>&2
;;
1)
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep -q "use port 122"; then
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then
exec "$0" "$hostname:122"
else
echo "$output" 1>&2
Expand Down
2 changes: 1 addition & 1 deletion bin/ghe-restore
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fi

# Restoring Elasticsearch to 11.10.3x via rsync requires GNU tar
if [ "$GHE_VERSION_MAJOR" -le 1 ] && [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
if ! tar --version | grep -q GNU; then
if ! tar --version | grep GNU >/dev/null; then
if ! command -v gtar >/dev/null 2>&1; then
echo "GNU tar is required. Aborting." >&2
exit 1
Expand Down
2 changes: 1 addition & 1 deletion share/github-backup-utils/ghe-backup-repositories-rsync
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ echo "
while [ \$sanity -lt $GHE_GIT_COOLDOWN_PERIOD ]; do
# note: the bracket synta[x] below is to prevent matches against the
# grep process itself.
if ps axo args | grep -q -E -e '^git( -.*)? nw-repac[k]( |$)' -e '^git( -.*)? g[c]( |$)'; then
if ps axo args | grep -E -e '^git( -.*)? nw-repac[k]( |$)' -e '^git( -.*)? g[c]( |$)' >/dev/null; then
sleep 1
sanity=\$(( sanity + 1 ))
else
Expand Down
2 changes: 1 addition & 1 deletion share/github-backup-utils/ghe-restore-es-rsync
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then
else
# Use GNU tar on BSDs.
TAR=tar
if ! tar --version | grep -q GNU; then
if ! tar --version | grep GNU >/dev/null; then
TAR=gtar
fi
cd "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
Expand Down
2 changes: 1 addition & 1 deletion share/github-backup-utils/ghe-ssh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ opts="-l $user $opts"

# Bail out with error if the simple command form is used with complex commands.
# Complex
if echo "$*" | grep -q "[|;]" || [ $(echo "$*" | wc -l) -gt 1 ]; then
if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then
echo "fatal: ghe-ssh: Attempt to invoke complex command with simple command form." 1>&2
echo "See ghe-ssh --help for more on correcting." 1>&2
exit 1
Expand Down

0 comments on commit f7c15c5

Please sign in to comment.