From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11700 invoked from network); 16 Jan 1997 09:38:59 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 16 Jan 1997 09:38:59 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id EAA24628; Thu, 16 Jan 1997 04:36:27 -0500 (EST) Resent-Date: Thu, 16 Jan 1997 04:36:27 -0500 (EST) Message-Id: <199701160937.KAA10290@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: #! problem In-reply-to: ""Bart Schaefer""'s message of "Wed, 15 Jan 1997 10:50:34 MET." <970115105034.ZM14647@candle.brasslantern.com> Date: Thu, 16 Jan 1997 10:37:43 +0100 From: Peter Stephenson Resent-Message-ID: <"jon8b3.0.i06.QQVto"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2798 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu "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 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.