zsh-workers
 help / color / mirror / code / Atom feed
* /bin/zsh -ce 'false; echo bug'
@ 1999-08-26  1:49 Matt Watson
  1999-08-26  8:26 ` Owen M. Astley
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Watson @ 1999-08-26  1:49 UTC (permalink / raw)
  To: zsh-workers

gnumake-3.74 wants to use "/bin/sh -ce <commandstring>" to exec a sub  
make. Unfortunately if zsh == sh, zsh doesn't grok the -ce as separate  
options, so it ignores the "e" and does not set ERREXIT.

Should it? Has anyone else come across this?

matt.


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

* Re: /bin/zsh -ce 'false; echo bug'
  1999-08-26  1:49 /bin/zsh -ce 'false; echo bug' Matt Watson
@ 1999-08-26  8:26 ` Owen M. Astley
  1999-08-26 18:06   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Owen M. Astley @ 1999-08-26  8:26 UTC (permalink / raw)
  To: zsh-workers

On Wed, 25 Aug 1999, Matt Watson wrote:

> gnumake-3.74 wants to use "/bin/sh -ce <commandstring>" to exec a sub  
> make. Unfortunately if zsh == sh, zsh doesn't grok the -ce as separate  
> options, so it ignores the "e" and does not set ERREXIT.
> 
> Should it? Has anyone else come across this?

I 'think' that POSIX doesn't allow for options of this type, it should be
written as -c -e <commandstring>.  However, I can't remember where I  read
that, and as most shells seem to cope with it, it should be done.

Is there any reason why parseargs() doesn't use getopt?

Owen



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

* Re: /bin/zsh -ce 'false; echo bug'
  1999-08-26  8:26 ` Owen M. Astley
@ 1999-08-26 18:06   ` Bart Schaefer
  1999-08-26 18:36     ` PATCH: " Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 1999-08-26 18:06 UTC (permalink / raw)
  To: Owen M. Astley, zsh-workers

On Aug 26,  9:26am, Owen M. Astley wrote:
> Subject: Re: /bin/zsh -ce 'false; echo bug'
> On Wed, 25 Aug 1999, Matt Watson wrote:
> 
> > gnumake-3.74 wants to use "/bin/sh -ce <commandstring>" to exec a sub  
> > make. Unfortunately if zsh == sh, zsh doesn't grok the -ce as separate  
> > options, so it ignores the "e" and does not set ERREXIT.
> 
> I 'think' that POSIX doesn't allow for options of this type, it should be
> written as -c -e <commandstring>.

Zsh interprets everything after the -c as part of the command, so that will
attempt to run a command named "-e".  If it really is the case that the
order of option letters doesn't matter (which appears to be true of bash,
at least), then zsh's option parser needs a bit more of a workover.


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

* PATCH: Re: /bin/zsh -ce 'false; echo bug'
  1999-08-26 18:06   ` Bart Schaefer
@ 1999-08-26 18:36     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 1999-08-26 18:36 UTC (permalink / raw)
  To: Owen M. Astley, zsh-workers

On Aug 26,  6:06pm, Bart Schaefer wrote:
> Subject: Re: /bin/zsh -ce 'false; echo bug'
> On Aug 26,  9:26am, Owen M. Astley wrote:
> > Subject: Re: /bin/zsh -ce 'false; echo bug'
> > On Wed, 25 Aug 1999, Matt Watson wrote:
> > 
> > > gnumake-3.74 wants to use "/bin/sh -ce <commandstring>"
> > 
> > I 'think' that POSIX doesn't allow for options of this type, it should be
> > written as -c -e <commandstring>.
> 
> Zsh interprets everything after the -c as part of the command, so that will
> attempt to run a command named "-e".

Here's a patch against 3.0.6, which should also apply to 3.1.6, to make
zsh's behavior consistent with bash's in this instance.  If you really want
to run a command named "-e" (or anything else starting with - or +), after
this patch you need one of

	zsh -cb ...
	zsh -c -b ...
	zsh -c- ...
	zsh -c - ...
	zsh -c -- ...

where "-b" is of course the csh-ism for "--".  It previously was neither
necessary nor possible to combine -b and -c in any order (whichever came
first was the only one interpreted).

I await word from the more extensively POSIXified readers on whether this
patch should be officially included.

Index: Src/init.c
===================================================================
@@ -236,14 +236,9 @@
 	    }
 
 	    if (**argv == 'c') {         /* -c command */
-		if (!*++argv) {
-		    zerr("string expected after -c", NULL, 0);
-		    exit(1);
-		}
-		cmd = *argv++;
+		cmd = *argv;
 		opts[INTERACTIVE] &= 1;
 		opts[SHINSTDIN] = 0;
-		goto doneoptions;
 	    } else if (**argv == 'o') {
 		if (!*++*argv)
 		    argv++;
@@ -276,6 +271,13 @@
     }
     doneoptions:
     paramlist = newlinklist();
+    if (cmd) {
+	if (!*argv) {
+	    zerr("string expected after -%s", cmd, 0);
+	    exit(1);
+	}
+	cmd = *argv++;
+    }
     if (*argv) {
 	if (unset(SHINSTDIN)) {
 	    argzero = *argv;


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

end of thread, other threads:[~1999-08-26 18:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-26  1:49 /bin/zsh -ce 'false; echo bug' Matt Watson
1999-08-26  8:26 ` Owen M. Astley
1999-08-26 18:06   ` Bart Schaefer
1999-08-26 18:36     ` PATCH: " 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).