zsh-users
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: var=$( typeset "$1" ) ... not within a function.
Date: Thu, 20 Oct 2022 20:44:37 +0200	[thread overview]
Message-ID: <CAN=4vMq_mdsEmc-hyRuo6wNsQBhHhgk7T-=oMyWmufsJ3C16ww@mail.gmail.com> (raw)
In-Reply-To: <d0422abc-e42f-0ccc-8521-e11dd0b1ccc8@eastlink.ca>

On Thu, Oct 20, 2022 at 8:39 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> On 2022-10-20 10:54, Roman Perepelitsa wrote:
> > The function is a red herring. If you run `unsetopt typeset_silent` in
> > the function or before invoking it, you'll see the same behavior as
> > you see in the script. If you read the description of this option,
> > you'll immediately see that everything works as expected. This option
> > controls `typeset` in exactly the way you are observing.
>
> But wouldn't my shell settings be inherited by the function?  It may be
> all as wanted, but it seems anomalous.  Why this special handling for
> typeset?  I can see that if you are setting or changing something, then
> the effect within a function will be different so various protections
> might be in order, but the simple display of an environment variable ...
> it seems strange.

There is no special handling of typeset within functions. `typeset
USER` behaves differently depending on whether typeset_silent is set
or not. You tested `typeset USER` in an environment where this option
is set and then in another environment where it's unset, and got
different results. This is expected. If you want `typeset USER` to
print, make sure to unset typeset_silent beforehand. However, what you
are doing is so bizarre that you should probably rewrite that code. I
would offer an alternative but I have no guess as to what you might be
trying to achieve.

Roman.


  reply	other threads:[~2022-10-20 18:45 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 17:21 Ray Andrews
2022-10-20 17:25 ` Roman Perepelitsa
2022-10-20 17:51   ` Ray Andrews
2022-10-20 17:54     ` Roman Perepelitsa
2022-10-20 18:38       ` Ray Andrews
2022-10-20 18:44         ` Roman Perepelitsa [this message]
2022-10-20 19:15           ` Ray Andrews
2022-10-20 19:35             ` Roman Perepelitsa
2022-10-20 20:48               ` Ray Andrews
2022-10-21  0:54                 ` Bart Schaefer
2022-10-21  1:58                   ` Ray Andrews
2022-10-21  2:25                     ` Bart Schaefer
2022-10-21 14:24                       ` Ray Andrews
2022-10-21 14:37                         ` Ray Andrews
2022-10-21 17:34                         ` Roman Perepelitsa
2022-11-01  5:00                       ` "typeset -p" inconsistency Bart Schaefer
2022-11-01 12:07                         ` Peter Stephenson
2022-11-01 12:40                         ` Ray Andrews
2022-11-01 19:08                           ` Bart Schaefer
2022-11-01 21:25                             ` Ray Andrews
2022-11-01 21:40                               ` Bart Schaefer
2022-11-01 22:46                                 ` Ray Andrews
2022-11-02  1:13                                   ` Lawrence Velázquez
2022-11-02  2:42                                     ` Ray Andrews
2022-11-02  3:11                                       ` Lawrence Velázquez
2022-11-02 12:56                                         ` Ray Andrews
2022-11-02 17:04                                           ` Bart Schaefer
2022-11-02 17:19                                             ` Ray Andrews
2022-11-02 18:21                                               ` Bart Schaefer
2022-11-02  3:10                                   ` Bart Schaefer
2022-11-02 17:09                                     ` Ray Andrews
2022-10-20 17:29 ` var=$( typeset "$1" ) ... not within a function Mikael Magnusson
2022-10-20 17:43   ` Ray Andrews
2022-10-21 17:33 ` Ray Andrews
2022-10-21 18:25   ` Bart Schaefer
2022-10-21 18:57     ` Ray Andrews
2022-10-21 19:02       ` Roman Perepelitsa
2022-10-21 19:06         ` Ray Andrews
2022-10-21 19:04     ` Ray Andrews

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='CAN=4vMq_mdsEmc-hyRuo6wNsQBhHhgk7T-=oMyWmufsJ3C16ww@mail.gmail.com' \
    --to=roman.perepelitsa@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).