Sujet : Re: Create functional processing pipe (without eval)?
De : lars (at) *nospam* cleo.beagle-ears.com (Lars Poulsen)
Groupes : comp.unix.shellDate : 07. May 2025, 13:58:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrn101mm6t.3upmf.lars@cleo.beagle-ears.com>
References : 1
User-Agent : slrn/1.0.3 (Linux)
On 2025-05-07, Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> wrote:
I'm pondering about creating a functional processing pipe, depending
on program parameters, and whether that's possible to achieve without
using 'eval'.
>
Say, the program is called "filter" and may accept 0..N parameters and
depending on the set of parameters the respective pipe functionality
shall be defined like
>
filter => cat
filter p1 => cat | func p1
filter p1 p2 => cat | func p1 | func p2
filter p1 p2 ... pN => cat | func p1 | func p2 | ... | func pN
>
where "func" is working as filter and accepts exactly one parameter.
>
(Because of reservations I have with 'eval' and quoting I'd like to
avoid that 'eval' indirection if possible.)
For a limited number of arguments, you could do it with a switch,
enumerating the variations. I can see the utility of such a feature.
It seems that you could do this with a small wrapper program (in your
favorite progframming language) activating the shell once the pipeline
has been constructed.
I would like to have this king of feature wrapped around grep in order
to do compounded keyword searches, but it's not a high priority.
Lars