Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145933268
D35836.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D35836.diff
View Options
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -255,7 +255,6 @@
int
histcmd(int argc, char **argv __unused)
{
- int ch;
const char *editor = NULL;
HistEvent he;
int lflg = 0, nflg = 0, rflg = 0, sflg = 0;
@@ -277,25 +276,29 @@
if (argc == 1)
error("missing history argument");
- while (not_fcnumber(*argptr) && (ch = nextopt("e:lnrs")) != '\0')
- switch ((char)ch) {
- case 'e':
- editor = shoptarg;
- break;
- case 'l':
- lflg = 1;
- break;
- case 'n':
- nflg = 1;
- break;
- case 'r':
- rflg = 1;
- break;
- case 's':
- sflg = 1;
- break;
- }
-
+ while (not_fcnumber(*argptr))
+ do {
+ switch (nextopt("e:lnrs")) {
+ case 'e':
+ editor = shoptarg;
+ break;
+ case 'l':
+ lflg = 1;
+ break;
+ case 'n':
+ nflg = 1;
+ break;
+ case 'r':
+ rflg = 1;
+ break;
+ case 's':
+ sflg = 1;
+ break;
+ case '\0':
+ goto operands;
+ }
+ } while (nextopt_optptr != NULL);
+operands:
savehandler = handler;
/*
* If executing...
diff --git a/bin/sh/options.c b/bin/sh/options.c
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -589,6 +589,9 @@
shoptarg = p;
p = NULL;
}
- nextopt_optptr = p;
+ if (p != NULL && *p != '\0')
+ nextopt_optptr = p;
+ else
+ nextopt_optptr = NULL;
return c;
}
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile
--- a/bin/sh/tests/builtins/Makefile
+++ b/bin/sh/tests/builtins/Makefile
@@ -94,6 +94,7 @@
${PACKAGE}FILES+= export1.0
${PACKAGE}FILES+= fc1.0
${PACKAGE}FILES+= fc2.0
+${PACKAGE}FILES+= fc3.0 fc3.0.stdout fc3.0.stderr
${PACKAGE}FILES+= for1.0
${PACKAGE}FILES+= for2.0
${PACKAGE}FILES+= for3.0
diff --git a/bin/sh/tests/builtins/fc3.0 b/bin/sh/tests/builtins/fc3.0
new file mode 100644
--- /dev/null
+++ b/bin/sh/tests/builtins/fc3.0
@@ -0,0 +1,9 @@
+export PS1='_ ' # cannot predict whether ran by root or not
+
+echo ': command1
+: command2
+: command3
+: command4
+fc -l -n -1
+fc -ln 2 3
+' | ENV= HISTFILE=/dev/null ${SH} +m -i
diff --git a/bin/sh/tests/builtins/fc3.0.stderr b/bin/sh/tests/builtins/fc3.0.stderr
new file mode 100644
--- /dev/null
+++ b/bin/sh/tests/builtins/fc3.0.stderr
@@ -0,0 +1 @@
+_ _ _ _ _ _ _ _
diff --git a/bin/sh/tests/builtins/fc3.0.stdout b/bin/sh/tests/builtins/fc3.0.stdout
new file mode 100644
--- /dev/null
+++ b/bin/sh/tests/builtins/fc3.0.stdout
@@ -0,0 +1,3 @@
+: command4
+: command2
+: command3
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 27, 7:30 AM (13 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29020866
Default Alt Text
D35836.diff (2 KB)
Attached To
Mode
D35836: sh: accept fc options grouped behind one '-'
Attached
Detach File
Event Timeline
Log In to Comment