zsh-workers
 help / color / mirror / code / Atom feed
* $(nooutput) problem
@ 1996-05-28  9:18 Peter Stephenson
  1996-05-28 11:34 ` Zoltan Hidvegi
  0 siblings, 1 reply; 15+ messages in thread
From: Peter Stephenson @ 1996-05-28  9:18 UTC (permalink / raw)
  To: Zsh hackers list

It seems care is needed: (1) if a command is not a simple one no
arguments may be necessary, so that having no arguments in execcmd()
is perfectly legal; (2) single word substitution needs to keeps its
arguments, for example the variable assignment code expects something
back from prefork(); (3) there's another bug/incompatibility (nearer
the latter than the former) resulting from the failure to delete empty
arguments:

% ksh -c 'cmd=; $cmd print foo'
foo
% zsh -fc 'cmd=; $cmd print foo'
zsh: permission denied: print

(which is certainly not the right answer in any case).

For these reasons I've fixed the problem by getting prefork() to junk
empty nodes if and only if it is not doing single word substitution,
and execcmd() to return if and only if it is a `simple' command with
no arguments.

*** Src/exec.c.empty	Fri May 17 16:25:20 1996
--- Src/exec.c	Tue May 28 10:35:36 1996
***************
*** 1200,1205 ****
--- 1200,1208 ----
      /* Do prefork substitutions */
      prefork(args, (((type == CCASE) ? 4 : 0) | (assign ? 2 : isset(MAGICEQUALSUBST))));
  
+     if (type == SIMPLE && empty(args))
+ 	return;
+ 
      /* Set up special parameter $_ */
      zsfree(underscore);
      if (nonempty(args) && (underscore = ztrdup((char *) getdata(lastnode(args)))))
*** Src/subst.c.empty	Tue May 28 10:34:04 1996
--- Src/subst.c	Tue May 28 10:41:15 1996
***************
*** 51,57 ****
  void
  prefork(LinkList list, int flags)
  {
!     LinkNode node;
  
      for (node = firstnode(list); node; incnode(node)) {
  	char *str, *str3;
--- 51,57 ----
  void
  prefork(LinkList list, int flags)
  {
!     LinkNode node, next;
  
      for (node = firstnode(list); node; incnode(node)) {
  	char *str, *str3;
***************
*** 69,77 ****
  	else if (!(node = stringsubst(list, node, flags & 4)))
  	    return;
      }
!     for (node = firstnode(list); node; incnode(node)) {
  	if (*(char *)getdata(node))
  	    remnulargs(getdata(node));
  	if (unset(IGNOREBRACES) && !(flags & 4))
  	    while (hasbraces(getdata(node)))
  		xpandbraces(list, &node);
--- 69,82 ----
  	else if (!(node = stringsubst(list, node, flags & 4)))
  	    return;
      }
!     for (node = firstnode(list); node; node = next) {
! 	next = nextnode(node);
  	if (*(char *)getdata(node))
  	    remnulargs(getdata(node));
+ 	else if (!(flags & 4)) {
+ 	    uremnode(list, node);
+ 	    continue;
+ 	}
  	if (unset(IGNOREBRACES) && !(flags & 4))
  	    while (hasbraces(getdata(node)))
  		xpandbraces(list, &node);


-- 
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] 15+ messages in thread
* Re: execcmd() reordering
@ 1996-05-30 18:05 Duncan Sinclair
  1996-05-30 19:10 ` Zoltan Hidvegi
  0 siblings, 1 reply; 15+ messages in thread
From: Duncan Sinclair @ 1996-05-30 18:05 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh hackers list


Peter wrote about exec stuff:
>Here's a biggish patch which does that. ...

>2) Now `nocorrect' must appear before any of the above.

Why?

>3) Also, variable assignment must appear before exec and friends.
>Again, this is natural and is required in other Bourne shell clones.

There's a flag (-k, I think) which will allow the bourne shell to take
variable assignments at any point of the command - does this work?

>5) `noglob typeset foo=~/file' do not do tilde expansion without...

>Maybe we should change.  Even
>magic_equal_subst is fairly sparing about when to expand:  it insists
>on the text before the = consisting only of characters which appear in
>identifiers, something I wrote but now rather regret.

Is this the stuff we argued about years ago?  I'm all for a change here.

>6) globbing is expanded before the fork.

I don't like this at all.

>Other than getting the
>prompt back an iota later when running background commands, I don't
>see this is a big deal.

When you've got a *huge* expansion which is 50% of the run-time
of the command, I'd like to be able to get on with other things.

>  (vii) I get extra brownie points for doing this the week before the
>        annual lattice field theory conference where I'm giving a
>        talk.  Please don't tell my collaborators :-).

Have fun!



Duncan.



^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: execcmd() reordering
@ 1996-05-31 10:15 Duncan Sinclair
  1996-05-31 10:55 ` Zoltan Hidvegi
  0 siblings, 1 reply; 15+ messages in thread
From: Duncan Sinclair @ 1996-05-31 10:15 UTC (permalink / raw)
  To: schaefer; +Cc: Zoltan Hidvegi, zsh-workers


"Barton E. Schaefer" writes:
>On May 30,  9:10pm, Zoltan Hidvegi wrote:
>} Subject: Re: execcmd() reordering
>}
>} > When you've got a *huge* expansion which is 50% of the run-time
>} > of the command, I'd like to be able to get on with other things.
>} 
>} You can use (foo **/*) &
>
>I tend to agree with Duncan here, I'm afraid.  I may not have any idea
>how large a list the glob is going to expand into; it's ridiculous to
>expect me to subshell every command that might do a glob.
>
>Furthermore, it'd be really nice to be able to stop (^Z) an unexpectedly
>huge glob and then "bg" it, or to interrupt it with ^C if I decide it was
>a mistake.

Oh, absolutely!  Does this change mean I can't interrupt long globs???
This would be terrible - esp. if the glob goes into a loop.

All the other things, I can live with.  This gives me nightmares.

Bye for now,


Duncan.



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

end of thread, other threads:[~1996-05-31 16:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-28  9:18 $(nooutput) problem Peter Stephenson
1996-05-28 11:34 ` Zoltan Hidvegi
1996-05-30 16:58   ` execcmd() reordering Peter Stephenson
1996-05-30 18:00     ` Zoltan Hidvegi
1996-05-30 18:26       ` Barton E. Schaefer
1996-05-30 18:46         ` Zoltan Hidvegi
1996-05-30 18:41       ` Zoltan Hidvegi
1996-05-30 18:05 Duncan Sinclair
1996-05-30 19:10 ` Zoltan Hidvegi
1996-05-30 19:52   ` Barton E. Schaefer
1996-05-31 14:32     ` Hrvoje Niksic
1996-05-31 10:15 Duncan Sinclair
1996-05-31 10:55 ` Zoltan Hidvegi
1996-05-31 11:58   ` Peter Stephenson
1996-05-31 16:28     ` Bart Schaefer

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