Re: Create functional processing pipe (without eval)?

Liste des GroupesRevenir à cu shell 
Sujet : Re: Create functional processing pipe (without eval)?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shell
Date : 07. May 2025, 23:55:31
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vvgod5$1a16t$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 07.05.2025 23:35, Christian Weisgerber wrote:
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
}
 

Hah, simple and straightforward, that's great!  8-)

Thanks :-)

Janis


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