zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: Ouch!  unset '*'
Date: Sat, 6 Feb 1999 13:18:20 -0800	[thread overview]
Message-ID: <990206131820.ZM30849@candle.brasslantern.com> (raw)

In the course of playing around with the (lack of) local-ness of $argv, I
happened upon this bit of behavior:
----------
zsh% function ouch() { unset '*' }
zsh% set a b c
zsh% echo $*
a b c
zsh% ouch
zsh% echo $*

zsh% echo $@
a b c
----------

Once you get into this state, there's NO WAY to get $* to exist again, in
any scope.  At least with argv you can do `argv=($@)` to get it to exist
again (and to track $* properly too).  Similarly, `unset @` will kill $@
in all scopes for the duration of the current shell and its subshells.

Subsequent to `unset @` or `unset '*'` you can use `set ...` to get the
positional parameters back (so $1 $2 etc. work again), but this does not
restore any of $argv, $*, or $@ that have been individually unset.

This seems to me to be a pretty bad situation.  Worse, `unset -m '*'`
actually crashes 3.1.5-pws-7, though it does not crash 3.0.5.  It appears
that

zsh% unset PWD OLDPWD

is a minimum command necessary to cause this crash, though there may be
other combinations of variables that crash the shell when simultaneously
unset.  I haven't had a chance to investigate further, but `unset -m '*'`
ought to work.

Back on the original question, it seems to me that it shouldn't be possible
to unset '*' and '@', only to make them empty.  Is it sufficient to mark
them read-only, or will that prevent assigning to argv?
 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


                 reply	other threads:[~1999-02-06 21:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=990206131820.ZM30849@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).