View | Details | Raw Unified | Return to bug 220587 | Differences between
and this patch

Collapse All | Expand All

(-)b/bin/sh/options.c (-6 / +7 lines)
Lines 41-46 __FBSDID("$FreeBSD$"); Link Here
41
#include <signal.h>
41
#include <signal.h>
42
#include <unistd.h>
42
#include <unistd.h>
43
#include <stdlib.h>
43
#include <stdlib.h>
44
#include <stdbool.h>
44
45
45
#include "shell.h"
46
#include "shell.h"
46
#define DEFINE_OPTIONS
47
#define DEFINE_OPTIONS
Lines 148-157 optschanged(void) Link Here
148
static void
149
static void
149
options(int cmdline)
150
options(int cmdline)
150
{
151
{
152
	bool saw_minus_c;
151
	char *kp, *p;
153
	char *kp, *p;
152
	int val;
154
	int val;
153
	int c;
155
	int c;
154
156
157
	saw_minus_c = false;
158
155
	if (cmdline)
159
	if (cmdline)
156
		minusc = NULL;
160
		minusc = NULL;
157
	while ((p = *argptr) != NULL) {
161
	while ((p = *argptr) != NULL) {
Lines 186-201 options(int cmdline) Link Here
186
			val = 0;
190
			val = 0;
187
		} else {
191
		} else {
188
			argptr--;
192
			argptr--;
193
			if (saw_minus_c)
194
				minusc = *argptr++;
189
			break;
195
			break;
190
		}
196
		}
191
		while ((c = *p++) != '\0') {
197
		while ((c = *p++) != '\0') {
192
			if (c == 'c' && cmdline) {
198
			if (c == 'c' && cmdline) {
193
				char *q;
199
				saw_minus_c = true;
194
195
				q = *argptr++;
196
				if (q == NULL || minusc != NULL)
197
					error("Bad -c option");
198
				minusc = q;
199
			} else if (c == 'o') {
200
			} else if (c == 'o') {
200
				minus_o(*argptr, val);
201
				minus_o(*argptr, val);
201
				if (*argptr)
202
				if (*argptr)
(-)b/bin/sh/tests/Makefile (+1 lines)
Lines 6-11 TESTS_SUBDIRS+= builtins Link Here
6
TESTS_SUBDIRS+=	errors
6
TESTS_SUBDIRS+=	errors
7
TESTS_SUBDIRS+=	execution
7
TESTS_SUBDIRS+=	execution
8
TESTS_SUBDIRS+=	expansion
8
TESTS_SUBDIRS+=	expansion
9
TESTS_SUBDIRS+=	options
9
TESTS_SUBDIRS+=	parameters
10
TESTS_SUBDIRS+=	parameters
10
TESTS_SUBDIRS+=	parser
11
TESTS_SUBDIRS+=	parser
11
TESTS_SUBDIRS+=	set-e
12
TESTS_SUBDIRS+=	set-e
(-)b/bin/sh/tests/options/Makefile (+16 lines)
Added Link Here
1
# $FreeBSD$
2
3
PACKAGE=	tests
4
5
TESTSDIR=	${TESTSBASE}/bin/sh/${.CURDIR:T}
6
7
.PATH: ${.CURDIR:H}
8
ATF_TESTS_SH=	functional_test
9
10
${PACKAGE}FILES+=	sh-ac1.0
11
${PACKAGE}FILES+=	sh-c1.0
12
${PACKAGE}FILES+=	sh-ca1.0
13
${PACKAGE}FILES+=	sh-m-c-a1.0
14
${PACKAGE}FILES+=	sh-mca1.0
15
16
.include <bsd.test.mk>
(-)b/bin/sh/tests/options/sh-ac1.0 (+5 lines)
Added Link Here
1
# $FreeBSD$
2
# Test that option processing ends after command_string and
3
# processes options before c
4
5
${SH} -ac 'echo $-:$0' -m | grep -qx "a:-m"
(-)b/bin/sh/tests/options/sh-c1.0 (+4 lines)
Added Link Here
1
# $FreeBSD$
2
# Test that option processing ends after command_string
3
4
${SH} -c 'echo $0 $@' -m foo | grep -qx -- "-m foo"
(-)b/bin/sh/tests/options/sh-ca1.0 (+5 lines)
Added Link Here
1
# $FreeBSD$
2
# Test that option processing ends after command_string and processes
3
# options after c
4
5
${SH} -ca 'echo $-:$0' -m | grep -qx "a:-m"
(-)b/bin/sh/tests/options/sh-m-c-a1.0 (+5 lines)
Added Link Here
1
# $FreeBSD$
2
# Test that option processing ends after command_string and processes
3
# options before and after c
4
5
${SH} -m -c -a 'echo $-:$0:$@' -foo -bar | grep -qx "ma:-foo:-bar"
(-)b/bin/sh/tests/options/sh-mca1.0 (+5 lines)
Added Link Here
1
# $FreeBSD$
2
# Test that option processing ends after command_string and processes
3
# flags before and after c
4
5
${SH} -mca 'echo $-:$0:$@' -foo -bar | grep -qx "ma:-foo:-bar"

Return to bug 220587