* Re: bug in zsh-2.6-beta21
[not found] <199606251855.UAA03602@woodstock.ens-lyon.fr>
@ 1996-06-25 19:15 ` Hrvoje Niksic
0 siblings, 0 replies; 4+ messages in thread
From: Hrvoje Niksic @ 1996-06-25 19:15 UTC (permalink / raw)
To: ZSH Workers Mailing List
Vincent Lefevre (Vincent.Lefevre@lip.ens-lyon.fr) wrote:
> This is OK. But under zsh 2.6-beta21:
>
> $ var=`echo "ab\ncd\nef"`
> $ echo $var
> ab
> cd
> ef
> $ var=`echo "ab\ncd\nef\n"`
> $ echo $var
> ab
> cd
> ef
> $
>
> The last "\n" is not printed.
I think this is good behaviour sh, ksh and bash also strip trailing
newlines. It should maybe be documented in the manual. E.g. bash
manual states:
$(command)
or
`command`
Bash performs the expansion by executing command and
replacing the command substitution with the standard out-
put of the command, with any trailing newlines deleted.
Whereas zsh manual says:
A command enclosed in parentheses preceded by a dollar
sign, like so: $(...) or quoted with grave accents: `...`
is replaced with its standard output. If the substitution
is not enclosed in double quotes, the output is broken
into words using the IFS parameter. The substitution
Removing trailing newlines is *not* specifically mentioned.
--
hniksic@srce.hr | Student of electrical engineering
hniksic@fly.cc.fer.hr | University of Zagreb, Croatia
------------------------------------------------------------------
`VI' - An editor used by those heretics that don't subscribe to
the Emacs religion.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in zsh-2.6-beta21
1996-07-01 8:22 ` Peter Stephenson
@ 1996-07-04 13:43 ` Peter Stephenson
0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 1996-07-04 13:43 UTC (permalink / raw)
To: Zsh hackers list
I wrote:
> alainc@nortel.ca wrote:
> > exec <3 <(ls -l)
> >
> > ---> zsh: no such file or directory: 3
> >
> > So far so good, but after that it seems that zle is broken as the up
> > arrow does not retrieve the last command entered.
>
> 1) Do we delay entersubsh() until after the redirections are handled?
Here's a patch for this. It's fairly simple, so I don't see any
problems with it.
*** Src/exec.c.subsh Thu Jul 4 15:30:39 1996
--- Src/exec.c Thu Jul 4 15:39:05 1996
***************
*** 1102,1108 ****
int save[10];
int fil, dfil, is_cursh, type, i;
int nullexec = 0, assign = 0, forked = 0;
! int is_shfunc = 0, is_builtin = 0;
/* Various flags to the command. */
int cflags = 0, checked = 0;
--- 1102,1108 ----
int save[10];
int fil, dfil, is_cursh, type, i;
int nullexec = 0, assign = 0, forked = 0;
! int is_shfunc = 0, is_builtin = 0, is_exec = 0;
/* Various flags to the command. */
int cflags = 0, checked = 0;
***************
*** 1420,1426 ****
/* This is an exec (real or fake) for an external command. *
* Note that any form of exec means that the subshell is fake *
* (but we may be in a subshell already). */
! entersubsh(how, 1, 1);
}
if (!(cflags & BINF_NOGLOB))
--- 1420,1426 ----
/* This is an exec (real or fake) for an external command. *
* Note that any form of exec means that the subshell is fake *
* (but we may be in a subshell already). */
! is_exec = 1;
}
if (!(cflags & BINF_NOGLOB))
***************
*** 1551,1556 ****
--- 1551,1563 ----
}
if (unset(NOEXEC)) {
+ /*
+ * We delay the entersubsh() to here when we are exec'ing
+ * the current shell (including a fake exec to run a builtin then
+ * exit) in case there is an error return.
+ */
+ if (is_exec)
+ entersubsh(how, 1, 1);
if (type >= CURSH) {
static int (*func[]) _((Cmd)) =
{
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in zsh-2.6-beta21
1996-06-21 14:29 Bug " alain (a.) caron
@ 1996-07-01 8:22 ` Peter Stephenson
1996-07-04 13:43 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1996-07-01 8:22 UTC (permalink / raw)
To: Zsh hackers list
alainc@nortel.ca wrote:
> I found the following bug in zsh-2.6-beta20 and beta21:
>
> I typed in the following:
>
> exec <3 <(ls -l)
>
> ---> zsh: no such file or directory: 3
>
> So far so good, but after that it seems that zle is broken as the up
> arrow does not retrieve the last command entered. Instead, the cursor
> just goes up. The tab character does not perform completion anymore,
> it just inserts a TAB. This was on a xterm window.
Zsh thinks the <(ls -l) is a real argument, which is not unreasonable,
so it thinks it's doing a real exec. However, the <3 open fails and
it decides it not going to do a real exec after all and returns from
execcmd(). The problem is that by that time entersubsh() has been
called to set zsh up for becoming an external program, so at the error
return lots of things (zle, monitor, job tables) are set up wrongly.
What's the answer?
1) Do we delay entersubsh() until after the redirections are handled?
I don't see why that shouldn't work. It might fix similar potential
problems with globlist. (Remember, it doesn't affect whether the
shell *really* becomes a subshell, just the settings.)
2) Or should this entersubsh() be delayed for safety until immediately
before the external command is executed?
2) Or is the answer to alter the behaviour of the third argument to
entersubsh (the `fake' flag) so that even less happens on an exec? (I
believe it needs to be called in this case really just to set up the
terminal for an external command and internal settings are irrelevant
--- but in this particular case we shouldn't really be setting
anything.)
By the way, I know you're not interested, but to me `depreciate' has
only ever meant `decrease in [usually monetary] value', whatever the
dictionary says. I've never in my life heard it used transitively ---
wrong side of the Atlantic, perhaps.
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Bug in zsh-2.6-beta21
@ 1996-06-21 14:29 alain (a.) caron
1996-07-01 8:22 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: alain (a.) caron @ 1996-06-21 14:29 UTC (permalink / raw)
To: zsh-workers
I found the following bug in zsh-2.6-beta20 and beta21:
I typed in the following:
exec <3 <(ls -l)
---> zsh: no such file or directory: 3
So far so good, but after that it seems that zle is broken as the up
arrow does not retrieve the last command entered. Instead, the cursor
just goes up. The tab character does not perform completion anymore,
it just inserts a TAB. This was on a xterm window.
I run zsh on HP-UX 9.01 and compiled it with the HP C compiler.
Regards,
Alain Caron
Nortel Technology, Montr?al, Qu?bec, Canada
email: alainc@nortel.ca
phone: 514-765-7718 or ESN 852-7718
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1996-07-04 13:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <199606251855.UAA03602@woodstock.ens-lyon.fr>
1996-06-25 19:15 ` bug in zsh-2.6-beta21 Hrvoje Niksic
1996-06-21 14:29 Bug " alain (a.) caron
1996-07-01 8:22 ` Peter Stephenson
1996-07-04 13:43 ` Peter Stephenson
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).