Skip to content

Instantly share code, notes, and snippets.

@dominiksalvet
dominiksalvet / grepe.sh
Last active November 13, 2019 13:53
POSIX grep wrapper. It succeeds even when no lines were selected.
#!/bin/sh
grep "$@" # execute the grep itself
grep_status="$?" # store its exit status
# suppress the empty selection error indicator (exit status of 1)
if [ "$grep_status" -eq 1 ]; then
grep_status=0
fi
exit "$grep_status" # exit with the modified exit status