zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu
Subject: Re: Bug Report: Env Vars and shell functions
Date: Fri, 12 Jul 1996 14:17:34 +0200	[thread overview]
Message-ID: <199607121217.OAA05821@hydra.ifh.de> (raw)
In-Reply-To: "aheading@jpmorgan.com"'s message of "Thu, 11 Jul 1996 23:11:24 MET." <199607112211.XAA18522@et-sun4.uk.jpmorgan.com>

aheading@jpmorgan.com wrote:
> On a related note, should the following not restore IFS?
> 
> sun4% IFS=@ set a@b@c@d; echo $IFS 
> @

This is a very ancient, revered and traditional bug, handed down since
time immemorial from the hand of pfalstad himself.  Special parameters
aren't restored after builtin constructs, unlike other parameters (at
least, after Zoltan's recent patches).  The problem is that there are
numerous different ways for setting builtins, and to do this properly
would mean save/restore functions for each.

One hack (actually, that's unfair --- I've used more or less the same
trick in a C++ parameter-reading class with templated virtual
functions, relying only on the presence of insertors and extractors
for the type in question, and it works vey nicely) that might work
here with a lot of parameters (but not such as SECONDS, which would
really need its own functions) is to retrieve the parameter as a
string value with the function used with $VAR for printing,
getstrvalue(), store that, then call the function that sets the
parameter from a string supplied on the command line with VAR=...,
setsparam().  This would do the trick reasonably simply for things
like PATH and IFS.  Probably care is needed, e.g. you can forget this
for arrays and what do you do if someone tries it with $path or
$cdpath?  Any comments?  Any implementations???

> And finally, why doesn't this work?
> sun4% local x=($(date))
> zsh: not an identifier: 10 BST 1996)

Do you mean, why can't you assign arrays from `local'?  I don't see any
prospect of doing it like that, since you would need special parsing
of the stuff in parentheses, which is somewhat abhorrent for something
that's supposed to look like an ordinary command; passing the argument
as a single word gets you into problems of how to split it later ---
and in the case shown, you still need special parsing to avoid getting
the expansion
     local x=Fri Jul 12 14:12:47 MET 1996
with fully-paid-up spaces between the arguments, which is what is
currently (and correctly) happening.  (Csh does special parsing after
`set', 'nuff said).  It should, however, definitely be possible to do
the equivalent of `set -A' with local or typeset, but it isn't.  This
is very nearly a bug.

Actually, I don't quite understand that error message, since it
suggests the last few words are passed as one, which isn't happening
to me.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



  reply	other threads:[~1996-07-12 12:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-08  3:49 Peter Bray
1996-07-08  8:58 ` Bart Schaefer
1996-07-08 12:49   ` Peter Stephenson
1996-07-10  2:33     ` Zoltan Hidvegi
1996-07-10 12:19       ` Vinnie Shelton
1996-07-10 13:45         ` Zoltan Hidvegi
1996-07-11 22:11           ` Anthony Heading
1996-07-12 12:17             ` Peter Stephenson [this message]
1996-07-12 15:27             ` Zoltan Hidvegi
1996-07-12 16:01               ` Anthony Heading
1996-07-12 17:18               ` Bart Schaefer
1996-07-12 17:43                 ` Zoltan Hidvegi

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=199607121217.OAA05821@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /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).