zsh-workers
 help / color / mirror / code / Atom feed
From: Martijn Dekker <martijn@inlv.org>
To: zsh-workers@zsh.org
Subject: Strange regression in zsh-git with redirecting output of 'readonly'
Date: Sun, 28 Jun 2015 00:19:19 +0200	[thread overview]
Message-ID: <558F2167.5080902@inlv.org> (raw)

There's a regression in current zsh git version: attempting to
redirecting the output of a "readonly" with assignment argument (i.e. a
potential error message) causes at least three kinds of different and
unpredictable strange behaviour. But in all three cases, the command
fails to work. In zsh 5.0.8 and earlier, all this works fine.

First manifestation:

On my Mac, when standard output is redirected, the command does
absolutely nothing. The variable is not assigned or even set.

% readonly var=testvalue >/dev/null
% echo ${var+set}

%

Second manifestation:

When redirecting standard error instead, something very strange happens.
But the variable is still not assigned or set.

% readonly var=testvalue 2>/dev/null
'!'=0
'#'=0
'$'=66831
'*'=()
-=bims
'?'=0
@=()
ARGC=0
HISTCMD=6
LINENO=6
PPID=81942
TTYIDLE=0
ZSH_EVAL_CONTEXT=toplevel
ZSH_SUBSHELL=0
status=0
zsh_eval_context=(toplevel)
% echo ${var+set}

%

Third manifestation:

In the initialization routine of the cross-platform shell library I'm
developing, I redirect standard error of 'readonly' to suppress an error
message and then check the result to see if the current shell supports
assignment with the 'readonly' command (one of a number of POSIX
compliance checks). The library is loaded as a dot script. The readonly
command in that context gives different behaviour still:

% . modernish
/Users/martijn/bin/modernish:76: no such file or directory:
%

The shell exits immediately after producing this error. The 'readonly'
command is on line 76 (which references no file or directory at all), so
that's a third manifestation of strange behaviour. The relevant snippet
from my library, starting at line 76, is:

readonly MSH_VERSION=0.01dev 2>| /dev/null
test "${MSH_VERSION:-}" = 0.01dev || {
        echo "[BUG000] 'readonly' command doesn't support assignment." 1>&2
        _Msh_defect=y
}

Nevertheless, when I issue that same 'readonly' command in interactive
mode, that shell variable dump happens again:

% readonly MSH_VERSION=0.01dev 2>| /dev/null
'!'=0
'#'=0
'$'=66839
'*'=()
-=bims
'?'=0
@=()
ARGC=0
HISTCMD=1
LINENO=1
PPID=81942
TTYIDLE=0
ZSH_EVAL_CONTEXT=toplevel
ZSH_SUBSHELL=0
status=0
zsh_eval_context=(toplevel)
%

I hope this has been sufficient information to figure out what's going on.

Thanks,

- Martijn


             reply	other threads:[~2015-06-27 22:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-27 22:19 Martijn Dekker [this message]
2015-06-27 22:45 ` Bart Schaefer
2015-06-27 22:55   ` Martijn Dekker
2015-06-27 22:55 ` Peter Stephenson
2015-06-27 23:08   ` Martijn Dekker

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=558F2167.5080902@inlv.org \
    --to=martijn@inlv.org \
    --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).