Re: Create functional processing pipe (without eval)?

Liste des GroupesRevenir à cu shell 
Sujet : Re: Create functional processing pipe (without eval)?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.shell
Date : 07. May 2025, 03:25:15
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250506192051.695@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (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.

The problem is that the number of pipes on the right hand side
depends on the number of arguments.

The number of pipes in a command pipe is a property of syntax;
it is something that needs eval.

If you're interested in being able to make this kind of code
transformation, perhaps you should start a project to add macros to a
shell. (An educated guess informs me that you'd likely choose Korn).

Macros avoid extra eval by taking advantage of the result of the
substitution being "naturally thrown into the path of the evaluator",
just like any other code that is not expanded by a macro.


--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
7 May 25 * Create functional processing pipe (without eval)?10Janis Papanagnou
7 May 25 +* Re: Create functional processing pipe (without eval)?2Kaz Kylheku
7 May 25 i`- Re: Create functional processing pipe (without eval)?1Janis Papanagnou
7 May 25 +* Re: Create functional processing pipe (without eval)?3Lars Poulsen
7 May 25 i`* Re: Create functional processing pipe (without eval)?2Janis Papanagnou
7 May 25 i `- Re: Create functional processing pipe (without eval)?1Janis Papanagnou
7 May 25 `* Re: Create functional processing pipe (without eval)?4Ben Bacarisse
7 May 25  `* Re: Create functional processing pipe (without eval)?3Janis Papanagnou
7 May 25   `* Re: Create functional processing pipe (without eval)?2Christian Weisgerber
7 May 25    `- Re: Create functional processing pipe (without eval)?1Janis Papanagnou

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal