zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Failure of "typeset" and exit status
Date: Tue, 12 May 2015 21:59:19 -0700	[thread overview]
Message-ID: <150512215919.ZM13985@torch.brasslantern.com> (raw)
In-Reply-To: <150511194320.ZM12928@torch.brasslantern.com>

On May 11,  7:43pm, Bart Schaefer wrote:
} Subject: Failure of "typeset" and exit status
}
} torch% ( () { typeset +g -m \* && echo No error } )
} (anon): failed to change user ID: operation not permitted
} (anon): failed to change group ID: operation not permitted
} (anon): failed to change effective user ID: operation not permitted
} (anon): failed to change effective group ID: operation not permitted
} No error
} torch% 
} 
} OK, that's not SO bad, except that "typeset +g -m \*" is intended to
} have made all the variables local ... which it has NOT, as you can see

OK, this is both more confusing and less borked than I thought.

The variables HAVE all been made local.  A subtlety that escaped me is
that in the example above, the read-only error on HISTCMD did not
happen, as it did below:

} (be sure to do this in a subshell if you try it yourself):
} 
} torch% ( () { typeset +g -m \* && unset -m \* } && typeset -p )
} (anon): failed to change user ID: operation not permitted
} (anon): failed to change group ID: operation not permitted
} (anon): failed to change effective user ID: operation not permitted
} (anon): failed to change effective group ID: operation not permitted
} (anon): read-only variable: HISTCMD
} torch% 

I forgot that "unset" on a read-only variable is a fatal error; it has
killed the entire subshell, so "typeset -p" never runs.  I incorrectly
interpreted the lack of output as meaning that all parameters were
unset, and thus were not local.

The *reason* that I believed that is because, when I ran that command
without the subshell parens, the prompt disappeared.  Turns out that
what's really happening there is that when PROMPT is made local, the
value of PS1 is erased because of the way the two are linked.  PS1 is
not yet a local at that point, so even when it is made local later the
damage has been done, localizing PROMPT has clobbered the global PS1
and thereby also clobbered the global PROMPT.

I'm entirely without ideas as to what we should do about that.  Likely
nothing except perhaps documenting it somewhere.

Now, the other question is, why is it a fatal error to attempt to change
a variable that is explicitly read-only, but only a warning to attempt
to change UID, GID, etc. when you do not have permission to do so?


  parent reply	other threads:[~2015-05-13  4:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12  2:43 Bart Schaefer
2015-05-12  8:42 ` Peter Stephenson
2015-05-12  9:12   ` Peter Stephenson
2015-05-13  4:59 ` Bart Schaefer [this message]
2015-05-13  8:39   ` Peter Stephenson
2015-05-13 15:48     ` Bart Schaefer
2015-05-13 16:38       ` Peter Stephenson
2015-05-13 17:50         ` Bart Schaefer

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=150512215919.ZM13985@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@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).