]> git.saurik.com Git - apple/shell_cmds.git/blobdiff - sh/options.c
shell_cmds-207.11.1.tar.gz
[apple/shell_cmds.git] / sh / options.c
index 25056b20e0d2b7b9af622e997bf71b47fcc75c01..0628e73ab0160142e528b0e8471e56035473e21a 100644 (file)
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
  * Copyright (c) 1991, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
@@ -13,7 +15,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -36,7 +38,7 @@ static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/options.c 296577 2016-03-09 21:00:57Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/options.c 326025 2017-11-20 19:49:47Z pfg $");
 
 #include <signal.h>
 #include <unistd.h>
@@ -131,7 +133,7 @@ procargs(int argc, char **argv)
 void
 optschanged(void)
 {
-       setinteractive(iflag);
+       setinteractive();
 #ifndef NO_HISTORY
        histedit();
 #endif
@@ -141,6 +143,8 @@ optschanged(void)
 /*
  * Process shell options.  The global variable argptr contains a pointer
  * to the argument list; we advance it past the options.
+ * If cmdline is true, process the shell's argv; otherwise, process arguments
+ * to the set special builtin.
  */
 
 static void
@@ -189,16 +193,11 @@ options(int cmdline)
                while ((c = *p++) != '\0') {
                        if (c == 'c' && cmdline) {
                                char *q;
-#ifdef NOHACK  /* removing this code allows sh -ce 'foo' for compat */
-                               if (*p == '\0')
-#endif
-                                       q = *argptr++;
+
+                               q = *argptr++;
                                if (q == NULL || minusc != NULL)
                                        error("Bad -c option");
                                minusc = q;
-#ifdef NOHACK
-                               break;
-#endif
                        } else if (c == 'o') {
                                minus_o(*argptr, val);
                                if (*argptr)
@@ -392,7 +391,7 @@ shiftcmd(int argc, char **argv)
 
 
 /*
- * The set command builtin.
+ * The set builtin command.
  */
 
 int
@@ -558,7 +557,7 @@ out:
 /*
  * Standard option processing (a la getopt) for builtin routines.  The
  * only argument that is passed to nextopt is the option string; the
- * other arguments are unnecessary.  It return the character, or '\0' on
+ * other arguments are unnecessary.  It returns the option, or '\0' on
  * end of input.
  */