cache content of stdin for reuse in _egrep_o(), this should fix #1364

This commit is contained in:
Zhang Cheng 2018-03-14 14:57:52 +08:00
parent 8ab8a6eefb
commit 59de5bd5e1

View File

@ -793,8 +793,9 @@ _sed_i() {
}
_egrep_o() {
if ! egrep -o "$1" 2>/dev/null; then
sed -n 's/.*\('"$1"'\).*/\1/p'
stdin=$(cat)
if ! echo "$stdin" | egrep -o "$1" 2>/dev/null; then
echo "$stdin" | sed -n 's/.*\('"$1"'\).*/\1/p'
fi
}