summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1996-12-21 13:21:57 +0000
committersteve <steve@FreeBSD.org>1996-12-21 13:21:57 +0000
commitf831af1d64c562c46e55018a32f3e675e98dbebf (patch)
tree0caea5f9942a8df5593baeac330c72caa8fb53e3 /bin
parentf48e1c2eb75f78b6fa7876df9cb708d7946b146c (diff)
downloadFreeBSD-src-f831af1d64c562c46e55018a32f3e675e98dbebf.zip
FreeBSD-src-f831af1d64c562c46e55018a32f3e675e98dbebf.tar.gz
Fix a problem caused by finger failure on my part. The builtin
getopts should now work as expected. This fix was in the NetBSD code that I was merging from but missed getting into FreeBSD's version because of 'drain bamage' on my part. Submitted by: NetBSD, joerg
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/options.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/sh/options.c b/bin/sh/options.c
index 26c62b5..0b2c6c1 100644
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: options.c,v 1.8 1996/10/29 03:12:48 steve Exp $
+ * $Id: options.c,v 1.9 1996/12/14 06:19:24 steve Exp $
*/
#ifndef lint
@@ -110,9 +110,11 @@ procargs(argc, argv)
setinputfile(commandname, 0);
}
/* POSIX 1003.2: first arg after -c cmd is $0, remainder $1... */
- if (*argptr && minusc)
+ if (argptr && minusc)
arg0 = *argptr++;
+
shellparam.p = argptr;
+ shellparam.reset = 1;
/* assert(shellparam.malloc == 0 && shellparam.nparam == 0); */
while (*argptr) {
shellparam.nparam++;
@@ -284,6 +286,7 @@ setparam(argv)
shellparam.nparam = nparam;
shellparam.p = newparam;
shellparam.optnext = NULL;
+ shellparam.reset = 1;
}
@@ -423,8 +426,9 @@ getopts(optstr, optvar, optfirst, optnext, optptr)
p = **optnext;
if (p == NULL || *p != '-' || *++p == '\0') {
atend:
- *optnext = NULL;
ind = *optnext - optfirst + 1;
+ *optnext = NULL;
+ p = NULL;
done = 1;
goto out;
}
OpenPOWER on IntegriCloud