zsh-workers
 help / color / mirror / code / Atom feed
* Strange regression in zsh-git with redirecting output of 'readonly'
@ 2015-06-27 22:19 Martijn Dekker
  2015-06-27 22:45 ` Bart Schaefer
  2015-06-27 22:55 ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Martijn Dekker @ 2015-06-27 22:19 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Strange regression in zsh-git with redirecting output of 'readonly'
  2015-06-27 22:19 Strange regression in zsh-git with redirecting output of 'readonly' Martijn Dekker
@ 2015-06-27 22:45 ` Bart Schaefer
  2015-06-27 22:55   ` Martijn Dekker
  2015-06-27 22:55 ` Peter Stephenson
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-06-27 22:45 UTC (permalink / raw)
  To: zsh-workers

Do these problems go away if you

disable -r readonly

at the start of the test?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Strange regression in zsh-git with redirecting output of 'readonly'
  2015-06-27 22:19 Strange regression in zsh-git with redirecting output of 'readonly' Martijn Dekker
  2015-06-27 22:45 ` Bart Schaefer
@ 2015-06-27 22:55 ` Peter Stephenson
  2015-06-27 23:08   ` Martijn Dekker
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2015-06-27 22:55 UTC (permalink / raw)
  To: zsh-workers

On Sun, 28 Jun 2015 00:19:19 +0200
Martijn Dekker <martijn@inlv.org> wrote:
> 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.

Does this fix it?

diff --git a/Src/parse.c b/Src/parse.c
index 477f8a0..09567fd 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1868,6 +1868,8 @@ par_simple(int *cmplx, int nr)
 	    *cmplx = c = 1;
 	    nrediradd = par_redir(&r, NULL);
 	    p += nrediradd;
+	    if (ppost)
+		ppost += nrediradd;
 	    sr += nrediradd;
 	} else if (tok == ENVSTRING) {
 	    char *ptr, *name, *str;

pws


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Strange regression in zsh-git with redirecting output of 'readonly'
  2015-06-27 22:45 ` Bart Schaefer
@ 2015-06-27 22:55   ` Martijn Dekker
  0 siblings, 0 replies; 5+ messages in thread
From: Martijn Dekker @ 2015-06-27 22:55 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer schreef op 28-06-15 om 00:45:
> Do these problems go away if you
> 
> disable -r readonly
> 
> at the start of the test?

Yes, they do.

- Martijn


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Strange regression in zsh-git with redirecting output of 'readonly'
  2015-06-27 22:55 ` Peter Stephenson
@ 2015-06-27 23:08   ` Martijn Dekker
  0 siblings, 0 replies; 5+ messages in thread
From: Martijn Dekker @ 2015-06-27 23:08 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson schreef op 28-06-15 om 00:55:
> Does this fix it?

Yes, like magic.

Thanks,

- M.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-27 23:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-27 22:19 Strange regression in zsh-git with redirecting output of 'readonly' Martijn Dekker
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

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).