aboutsummaryrefslogtreecommitdiff
path: root/bin/sh/options.c
diff options
context:
space:
mode:
authorGarance A Drosehn <gad@FreeBSD.org>2005-05-16 04:32:41 +0000
committerGarance A Drosehn <gad@FreeBSD.org>2005-05-16 04:32:41 +0000
commit01c7bd5378252005aa3f9ccdaa5bcaf978be9039 (patch)
tree0ace0d6f355638f5e9082f2d0c7ee794246fe12f /bin/sh/options.c
parent31ae05021122b9925f4160dafa10e35a961aacad (diff)
Notes
Diffstat (limited to 'bin/sh/options.c')
-rw-r--r--bin/sh/options.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/bin/sh/options.c b/bin/sh/options.c
index bc60a96f4e320..d2c4a982cf490 100644
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -138,7 +138,7 @@ optschanged(void)
STATIC void
options(int cmdline)
{
- char *p;
+ char *kp, *p;
int val;
int c;
@@ -153,6 +153,25 @@ options(int cmdline)
goto end_options1;
if (p[0] == '-' && p[1] == '\0')
goto end_options2;
+ /**
+ * For the benefit of `#!' lines in shell scripts,
+ * treat a string of '-- *#.*' the same as '--'.
+ * This is needed so that a script starting with:
+ * #!/bin/sh -- # -*- perl -*-
+ * will continue to work after a change is made to
+ * kern/imgact_shell.c to NOT token-ize the options
+ * specified on a '#!' line. A bit of a kludge,
+ * but that trick is recommended in documentation
+ * for some scripting languages, and we might as
+ * well continue to support it.
+ */
+ if (p[0] == '-') {
+ kp = p + 1;
+ while (*kp == ' ' || *kp == '\t')
+ kp++;
+ if (*kp == '#' || *kp == '\0')
+ goto end_options2;
+ }
} else if (c == '+') {
val = 0;
} else {