zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: Zsh Users <zsh-users@zsh.org>
Subject: piping surprise
Date: Wed, 3 Apr 2024 06:17:14 -0700	[thread overview]
Message-ID: <a35f798c-0e1e-49cc-89d1-98c28d62bdfb@eastlink.ca> (raw)

[-- Attachment #1: Type: text/plain, Size: 665 bytes --]

Speaking of female logic, I stumbled upon this:

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?



[-- Attachment #2: Type: text/html, Size: 1292 bytes --]

             reply	other threads:[~2024-04-03 13:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 13:17 Ray Andrews [this message]
2024-04-03 15:00 ` Mikael Magnusson
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=a35f798c-0e1e-49cc-89d1-98c28d62bdfb@eastlink.ca \
    --to=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).