Skip to content

Commit

Permalink
chore: use more portable grep
Browse files Browse the repository at this point in the history
replace newer quiet `grep` with more portable syntax for vintage `grep`
implementations:
`grep -q foo` → `grep foo >/dev/null 2>&1`

Signed-off-by: Lucas Larson <[email protected]>
  • Loading branch information
LucasLarson committed May 11, 2024
1 parent 558f506 commit 630b0e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ hash_abbreviate() {
done
shift "$((OPTIND - 1))"
for hash in "$@"; do
if printf -- '%s' "${hash-}" | command grep -E -q -w -e '^[[:xdigit:]]{4,40}$'; then
if printf -- '%s' "${hash-}" | command grep -E -w -e '^[[:xdigit:]]{4,40}$' >/dev/null 2>&1; then
printf -- '%s\n' "${hash-}" | command cut -c 1-"${length:-"$(command git config --get core.abbrev 2>/dev/null || printf -- '7')"}"
# prevent copying trailing newline with `tr` and
# hide clipboard errors because `pbcopy` is not common
Expand Down
4 changes: 2 additions & 2 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ command -v -- less >/dev/null 2>&1 || {
# https://wiki.alpinelinux.org/w/index.php?oldid=18038&title=Alpine_newbie_apk_packages#coreutils_libc_and_utmps_in_alpine
install coreutils
{ command -p -- test -x '/usr/bin/coreutils' &&
command -p -- find --version >/dev/null 2>&1 | command -p -- grep -q -e 'findutils'; } || {
command -p -- find --version >/dev/null 2>&1 | command -p -- grep -e 'findutils' >/dev/null 2>&1; } || {
{ set +o xtrace; } 2>/dev/null
command -p -- printf -- 'installing Linux utilities...\n' >&2
set -o xtrace
Expand Down Expand Up @@ -291,7 +291,7 @@ command -p -- find -- . -type d -links 2 \
# if zsh is available, then replace bash, ash, and sh with zsh in `/etc/passwd`
command -p -- test -w '/etc/passwd' &&
command -v -- zsh >/dev/null 2>&1 &&
command -p -- grep -E -e '/bin/b?a?sh' '/etc/passwd' 2>&1 &&
command -p -- grep -E -e '/bin/b?a?sh' '/etc/passwd' >/dev/null 2>&1 &&
command -p -- cp -- '/etc/passwd' '/etc/passwd-'"${now-}" &&
command -p -- sed -e 's|/bin/b\{0,1\}a\{0,1\}sh$|'"$(command -v -- zsh)"'|' '/etc/passwd-'"${now-}" >'/etc/passwd'

Expand Down

0 comments on commit 630b0e9

Please sign in to comment.