From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: #! problem
Date: Thu, 16 Jan 1997 10:37:43 +0100 [thread overview]
Message-ID: <199701160937.KAA10290@hydra.ifh.de> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Wed, 15 Jan 1997 10:50:34 MET." <970115105034.ZM14647@candle.brasslantern.com>
"Bart Schaefer" wrote:
> On Jan 15, 10:37am, Peter Stephenson wrote:
> } Subject: #! problem
> }
> } Somebody here tried something like:
> }
> } #!/bin/zsh -f
> } # ^^^^empty spaces added here
>
> As opposed to ... full spaces?
mmph.
> 2. Stop parsing options at whitespace, and completely ignore it and
> all the characters that come after it. I believe BSD 4.2 csh did
> this, if I'm remembering correctly my early days of feeling my way
> through scripting.
>
> 3. As (2), but issue an error if there's anything other than whitespace
> in the trailing part. I think this is the most reasonable choice, as
> it doesn't silently drop stuff from the #! line (which was mystifying
> when it happened in csh, which is why I'm pretty sure I remember it).
This sounds OK to me, and that's what I've written.
There's one common case (common to me, anyway, I never realised it
wasn't going to work) which isn't handled:
#!/bin/zsh -f -*-ksh-*-
(important if you don't like the new shell-mode in Emacs.) Looks like
I'll have to get used to writing
#!/bin/zsh -f-*-ksh-*-
which also works as the second - terminates processing. I suppose
everybody else knew that already.
*** Doc/zsh.texi.opt Thu Jan 16 09:51:24 1997
--- Doc/zsh.texi Thu Jan 16 10:33:55 1997
***************
*** 5483,5488 ****
--- 5483,5499 ----
the specification of option names by glob patterns, clashes with the use of
@samp{-m} for setting the @code{MONITOR} option.
+ @noindent
+ Note also that whitespace at the end of an otherwise valid option
+ string is ignored. This is provided for the case when a zsh script is
+ invoked via a line of the form
+
+ @code{#!/bin/zsh -@var{option-string}}
+
+ @noindent
+ as many systems pass the text following the interpreter name with no
+ further processing. If any other text follows the whitespace an error
+ is signalled.
@node Shell Builtin Commands, Programmable Completion, Options, Top
@chapter Shell Builtin Commands
*** Doc/zshoptions.man.opt Thu Jan 16 09:51:19 1997
--- Doc/zshoptions.man Thu Jan 16 10:33:01 1997
***************
*** 649,651 ****
--- 649,663 ----
.BR unsetopt ,
allowing the specification of option names by glob patterns,
clashes with the use of \-\fBm\fP for setting the MONITOR option.
+ .PP
+ Note also that whitespace at the end of an otherwise valid option
+ string is ignored. This is provided for the case when a zsh script is
+ invoked via a line of the form
+ .PP
+ .nf
+ #!/bin/zsh \-\fIoption_string\fP
+ .fi
+ .PP
+ as many systems pass the text following the interpreter name with no
+ further processing. If any other text follows the whitespace an error
+ is signalled.
*** Src/init.c.opt Wed Jan 8 11:13:10 1997
--- Src/init.c Thu Jan 16 10:31:15 1997
***************
*** 205,210 ****
--- 205,211 ----
/* loop through command line options (begins with "-" or "+") */
while (*argv && (**argv == '-' || **argv == '+')) {
+ char *args = *argv;
action = (**argv == '-');
if(!argv[0][1])
*argv = "--";
***************
*** 237,242 ****
--- 238,251 ----
zerr("no such option: %s", *argv, 0);
else
dosetopt(optno, action, 1);
+ break;
+ } else if (isspace(**argv)) {
+ /* zsh's typtab not yet set, have to use ctype */
+ while (*++*argv)
+ if (!isspace(**argv)) {
+ zerr("bad option string: `%s'", args, 0);
+ exit(1);
+ }
break;
} else {
if (!(optno = optlookupc(**argv))) {
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
prev parent reply other threads:[~1997-01-16 9:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-01-15 9:37 Peter Stephenson
1997-01-15 18:50 ` Bart Schaefer
1997-01-16 9:37 ` Peter Stephenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199701160937.KAA10290@hydra.ifh.de \
--to=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).