Sujet : Re: Create functional processing pipe (without eval)?
De : naddy (at) *nospam* mips.inka.de (Christian Weisgerber)
Groupes : comp.unix.shellDate : 07. May 2025, 22:35:16
Autres entêtes
Message-ID : <slrn101nkgk.12bd.naddy@lorvorc.mips.inka.de>
References : 1 2 3
User-Agent : slrn/1.0.3 (FreeBSD)
On 2025-05-07, Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> wrote:
function recurse
{
if [[ $# -ge 1 ]]
then grep "$1" | (shift; recurse "$@")
else cat
fi
}
>
I certainly need a "transparent" (idempotent) function if there are no
arguments provided, so a 'cat' is what I need in that case. (An empty
output would definitely be wrong for me.) And the unnecessary 'cat' at
the pipe end(s) is an acceptable unimportant degradation (for me). But
if you have an idea how to remove it... :-)
recurse()
{
case $# in
0) cat ;;
1) grep "$1" ;;
*) grep "$1" | (shift; recurse "$@") ;;
esac
}
-- Christian "naddy" Weisgerber naddy@mips.inka.de