zsh-workers
 help / color / mirror / code / Atom feed
* LINENO behaviour in sh mode
@ 2017-03-20  2:57 Martijn Dekker
  2017-03-20  3:41 ` Martijn Dekker
  2017-03-23  2:45 ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Martijn Dekker @ 2017-03-20  2:57 UTC (permalink / raw)
  To: Zsh hackers list

Test script:
printf "$LINENO "
printf "$LINENO "
eval '	printf "$LINENO "
	printf "$LINENO "
	printf "$LINENO " '
printf "$LINENO\n"

Output on various shells:
            bash: 1 2 5 6 7 6  (?!)
     {m,l,pd}ksh: 1 2 0 0 0 6  (?)
      AT&T ksh88: 1 2 3 3 3 6
      AT&T ksh93: 1 2 1 2 3 6
      FreeBSD sh: 1 2 1 2 3 6
            dash: 1 2 1 2 3 6
            yash: 1 2 1 2 3 6
    zsh (native): 1 2 1 2 3 6
        zsh (sh): 1 2 3 3 3 6  (like ksh88)

Since ksh88 is dead and buried (even Solaris now has ksh93 as their
/bin/sh), it looks like zsh's "sh" mode is not emulating any current sh.
Maybe 'emulate sh' should no longer turn off the EVAL_LINENO option.

- M.


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

* Re: LINENO behaviour in sh mode
  2017-03-20  2:57 LINENO behaviour in sh mode Martijn Dekker
@ 2017-03-20  3:41 ` Martijn Dekker
  2017-03-23  2:45 ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Martijn Dekker @ 2017-03-20  3:41 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

Op 20-03-17 om 03:57 schreef Martijn Dekker:
> Maybe 'emulate sh' should no longer turn off the EVAL_LINENO option.

Which turns out to be easy to accomplish.

Seems prudent to leave it turned off for ksh mode, as that emulates
ksh88 more than it does ksh93.

- M.


[-- Attachment #2: evallineno-sh.patch --]
[-- Type: text/x-patch, Size: 678 bytes --]

diff --git a/Src/options.c b/Src/options.c
index 2b5795b..5b068b3 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -131,7 +131,7 @@ static struct optname optns[] = {
 {{NULL, "exec",		      OPT_ALL},			 EXECOPT},
 {{NULL, "extendedglob",	      OPT_EMULATE},		 EXTENDEDGLOB},
 {{NULL, "extendedhistory",    OPT_CSH},			 EXTENDEDHISTORY},
-{{NULL, "evallineno",	      OPT_EMULATE|OPT_ZSH},	 EVALLINENO},
+{{NULL, "evallineno",	      OPT_EMULATE|OPT_SH|OPT_ZSH}, EVALLINENO},
 {{NULL, "flowcontrol",	      OPT_ALL},			 FLOWCONTROL},
 {{NULL, "forcefloat",         0},                        FORCEFLOAT},
 {{NULL, "functionargzero",    OPT_EMULATE|OPT_NONBOURNE},FUNCTIONARGZERO},

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

* Re: LINENO behaviour in sh mode
  2017-03-20  2:57 LINENO behaviour in sh mode Martijn Dekker
  2017-03-20  3:41 ` Martijn Dekker
@ 2017-03-23  2:45 ` Bart Schaefer
  2017-03-23  3:09   ` Martijn Dekker
  1 sibling, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2017-03-23  2:45 UTC (permalink / raw)
  To: Martijn Dekker, Zsh hackers list

On Mar 20,  3:57am, Martijn Dekker wrote:
}
} Output on various shells:
}             bash: 1 2 5 6 7 6  (?!)

Clearly bash is incrementing LINENO through the parse of the eval and
then continuing to increment it through the execution.

I'm mildly surprised that no shell prints "1 2 3 4 5 6".

}         zsh (sh): 1 2 3 3 3 6  (like ksh88)
} 
} Since ksh88 is dead and buried (even Solaris now has ksh93 as their
} /bin/sh), it looks like zsh's "sh" mode is not emulating any current sh.
} Maybe 'emulate sh' should no longer turn off the EVAL_LINENO option.

You're forgetting about the second effect of this, which is to print
"(eval)" in xtrace output instead of the script or function name.  Try
your test again with "set -x" ... Do we need a separate option?

Also, how should the doc be updated, given that csh emulation would
become the outlier?


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

* Re: LINENO behaviour in sh mode
  2017-03-23  2:45 ` Bart Schaefer
@ 2017-03-23  3:09   ` Martijn Dekker
  2017-03-23 16:11     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Martijn Dekker @ 2017-03-23  3:09 UTC (permalink / raw)
  To: zsh-workers

Op 23-03-17 om 03:45 schreef Bart Schaefer:
> On Mar 20,  3:57am, Martijn Dekker wrote:
> }
> } Output on various shells:
> }             bash: 1 2 5 6 7 6  (?!)
> 
> Clearly bash is incrementing LINENO through the parse of the eval and
> then continuing to increment it through the execution.

Yes. http://lists.gnu.org/archive/html/bug-bash/2017-03/msg00128.html

> I'm mildly surprised that no shell prints "1 2 3 4 5 6".

Well, I can see how that would be non-trivial to pull off.

> }         zsh (sh): 1 2 3 3 3 6  (like ksh88)
> } 
> } Since ksh88 is dead and buried (even Solaris now has ksh93 as their
> } /bin/sh), it looks like zsh's "sh" mode is not emulating any current sh.
> } Maybe 'emulate sh' should no longer turn off the EVAL_LINENO option.
> 
> You're forgetting about the second effect of this, which is to print
> "(eval)" in xtrace output instead of the script or function name.  Try
> your test again with "set -x" ... 

Yes, but how is that a problem? Seems like logical behaviour to me.

If zsh is launched as sh, by default it prints neither of those anyway.

> Do we need a separate option?

Something this minor hardly seems worth a separate option, IMHO.

In any case, for some reason my message took three days to get through
to the list and meanwhile there's an update: mksh has just been patched
to fix the bug where LINENO is always zero for eval or alias expansion.
The only simple way to patch it was to make it act like ksh88, so as of
the next mksh release there will once again be a current shell with a
LINENO that acts like ksh88.

(BTW, Bart, all your messages have been coming through zwh-workers in
duplicate for quite some time now, the second copy always about 2K
larger than the first due to extra routing headers.)

Thanks,

- M.


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

* Re: LINENO behaviour in sh mode
  2017-03-23  3:09   ` Martijn Dekker
@ 2017-03-23 16:11     ` Bart Schaefer
  2017-03-23 16:23       ` Duplicate messages (was Re: LINENO behaviour in sh mode) Aaron Schrab
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2017-03-23 16:11 UTC (permalink / raw)
  To: zsh-workers

On Mar 23,  4:09am, Martijn Dekker wrote:
}
} Op 23-03-17 om 03:45 schreef Bart Schaefer:
} > You're forgetting about the second effect of this, which is to print
} > "(eval)" in xtrace output instead of the script or function name.  Try
} > your test again with "set -x" ... 
} 
} Yes, but how is that a problem? Seems like logical behaviour to me.

Just pointing out that it's another difference that will appear.  It
may not matter but someone might care about their prompt changing etc.

} (BTW, Bart, all your messages have been coming through zwh-workers in
} duplicate for quite some time now, the second copy always about 2K
} larger than the first due to extra routing headers.)

Thanks for letting me know; that means at least some of gmail's SMTP
relays are off the blocklist used by primenet.  Gmail inbox suppresses
duplicates and so apparently does the list archive (do both copies of
what you see have the same X-Seq ?) so I can't see the effect myself.

I'll try this one without the second copy and see what happens.


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

* Duplicate messages (was Re: LINENO behaviour in sh mode)
  2017-03-23 16:11     ` Bart Schaefer
@ 2017-03-23 16:23       ` Aaron Schrab
  0 siblings, 0 replies; 6+ messages in thread
From: Aaron Schrab @ 2017-03-23 16:23 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

At 09:11 -0700 23 Mar 2017, Bart Schaefer <schaefer@brasslantern.com> wrote:
>} (BTW, Bart, all your messages have been coming through zwh-workers in
>} duplicate for quite some time now, the second copy always about 2K
>} larger than the first due to extra routing headers.)
>
>Thanks for letting me know; that means at least some of gmail's SMTP
>relays are off the blocklist used by primenet. 

Based on what I'd seen that was always the case. I started seeing dups 
pretty much as soon as that work around was put into place. I'd though 
that was expected, so I just enabled duplicate filtering on my end.

>(do both copies of >what you see have the same X-Seq ?)

No, each copy has its own X-Seq. (I keep copies of all incoming mail 
before any filtering is done.)

>I'll try this one without the second copy and see what happens.

It obviously made it to the list.


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

end of thread, other threads:[~2017-03-23 16:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-20  2:57 LINENO behaviour in sh mode Martijn Dekker
2017-03-20  3:41 ` Martijn Dekker
2017-03-23  2:45 ` Bart Schaefer
2017-03-23  3:09   ` Martijn Dekker
2017-03-23 16:11     ` Bart Schaefer
2017-03-23 16:23       ` Duplicate messages (was Re: LINENO behaviour in sh mode) Aaron Schrab

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