diff --git a/home/shrc b/home/shrc index adafcd2..2a285f6 100644 --- a/home/shrc +++ b/home/shrc @@ -128,9 +128,6 @@ gdp() { ### @- invoke `gd` to diff a commit from its parent. the commit defaults alias ash="PS1='$ ' busybox ash" alias cort='LC_ALL=C sort' -alias grop='grep -oP' ### @- invoke grep with `-oP`. -### **NOTE:** there also exists a grop(1) program provided by -### the *grop* package that i don't use. alias pip="maybesudo -H pip3" alias revend='objcopy -I binary -O binary --reverse-bytes=4' ### @- reverse the 4-byte endianness of a single file. *this is an in-place operation!* alias clone='maybesudo rsync -aHA --info=progress2 --no-i-r' ### @- invoke rsync suitably for creating virtually indistinguishable copies of files. diff --git a/sh/grop b/sh/grop new file mode 100644 index 0000000..f73a44b --- /dev/null +++ b/sh/grop @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +# YES_ZSH +# YES_BASH +# YES_DASH +# YES_ASH + +# TODO: check for existence of grep -P; write a perl-based fallback. +grop() { ### @- invoke grep with `-oP`. + ### **NOTE:** there also exists a grop(1) program provided by + ### the *grop* package that i don't use. + argc $# -ge 1 grop || return + grep -oP -- "$@" +} + +[ -n "${preload+-}" ] || . ~/sh/preload || exit 2 +eval ${preload:-preload} argc +[ -n "${preload+-}" ] || grop "$@"