zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: piping surprise
Date: Wed, 3 Apr 2024 17:00:24 +0200	[thread overview]
Message-ID: <CAHYJk3QPg-nA=-6HOtBTvYSqjB+AocYWmOkFna61CG_hPDxwUw@mail.gmail.com> (raw)
In-Reply-To: <a35f798c-0e1e-49cc-89d1-98c28d62bdfb@eastlink.ca>

On Wed, Apr 3, 2024 at 3:19 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Speaking of female logic, I stumbled upon this:

Keep your sexism to yourself, although in this case you're just
insulting yourself anyway.

> function bbb ()
> {
>     vvar=4
>     print -l "\nShall\nI\ncompare thee\nto a\nsummer's day?"
> }
>
> function aaa ()
> {
>     local vvar=1
>     bbb
>     echo "\nvvar is $vvar"
>     vvar=2
>     echo "\n=============\n"
>     bbb | grep 'a'
>     echo "\nvvar is $vvar"
> }
>
> %  aaa
>
> Shall
> I
> compare thee
> to a
> summer's day?
>
> vvar is 4
>
> =============
>
> Shall
> compare thee
> to a
> summer's day?
>
> vvar is 2
>
> ------------------------------------------------------------------
>
> By what thinking does the piping of a function's output thru grep cancel the assignment to the variable?  Do we really want that?

Surely by now you know how pipes work? One process has to run on
either side of the pipe, only one of them can be your current shell
(the one on the left is not it).

-- 
Mikael Magnusson


  reply	other threads:[~2024-04-03 15:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 13:17 Ray Andrews
2024-04-03 15:00 ` Mikael Magnusson [this message]
2024-04-03 15:49   ` Ray Andrews
2024-04-05 20:32     ` Bart Schaefer
2024-04-05 23:11       ` Ray Andrews
2024-04-07  6:34       ` Lawrence Velázquez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYJk3QPg-nA=-6HOtBTvYSqjB+AocYWmOkFna61CG_hPDxwUw@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).