Deutsch   English   Français   Italiano  
<slrn101mm6t.3upmf.lars@cleo.beagle-ears.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Lars Poulsen <lars@cleo.beagle-ears.com>
Newsgroups: comp.unix.shell
Subject: Re: Create functional processing pipe (without eval)?
Date: Wed, 7 May 2025 12:58:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <slrn101mm6t.3upmf.lars@cleo.beagle-ears.com>
References: <vveev6$dll3$1@dont-email.me>
Injection-Date: Wed, 07 May 2025 14:58:05 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b15ad356a79a2c63728b8b652aeea9cd";
	logging-data="1087186"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX199e6yIlLcrBCEPhDHyQ7hcPL1OlXZBdNM="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:GDsLZsmLfuSt4ArARoHR15OK1Dg=

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