FreeBSD Bugzilla – Attachment 250294 Details for
Bug 278653
sh: fix sh -c -e cmd as per POSIX
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
fix sh -c -e cmd as per POSIX
sh.patch (text/plain), 2.18 KB, created by
Christian Weisgerber
on 2024-04-29 15:07:27 UTC
(
hide
)
Description:
fix sh -c -e cmd as per POSIX
Filename:
MIME Type:
Creator:
Christian Weisgerber
Created:
2024-04-29 15:07:27 UTC
Size:
2.18 KB
patch
obsolete
>----------------------------------------------- >commit 3a9ec8018a4517f4aa4890ecc50246e44a52fa14 (sh) >from: Christian Weisgerber <naddy@mips.inka.de> >date: Mon Apr 29 14:47:53 2024 UTC > > sh: fix sh -c -e cmd as per POSIX > > From NetBSD. > >diff 86fbb05da1aed64eb9b09d7f3b2cd72048c959c1 3a9ec8018a4517f4aa4890ecc50246e44a52fa14 >commit - 86fbb05da1aed64eb9b09d7f3b2cd72048c959c1 >commit + 3a9ec8018a4517f4aa4890ecc50246e44a52fa14 >blob - 2dab8f4ea998c831acc66eb2d9f41f48b2e19ac0 >blob + 1c459e3769754292cd37cf99efb6165925e5dd52 >--- bin/sh/options.c >+++ bin/sh/options.c >@@ -108,8 +108,13 @@ procargs(int argc, char **argv) > commandname = arg0 = scriptname; > } > /* POSIX 1003.2: first arg after -c cmd is $0, remainder $1... */ >- if (argptr && minusc && *argptr) >- arg0 = *argptr++; >+ if (minusc != NULL) { >+ if (argptr == NULL || *argptr == NULL) >+ error("Bad -c option"); >+ minusc = *argptr++; >+ if (*argptr != 0) >+ arg0 = *argptr++; >+ } > > shellparam.p = argptr; > shellparam.reset = 1; >@@ -142,6 +147,7 @@ optschanged(void) > static void > options(int cmdline) > { >+ static char empty[] = ""; > char *kp, *p; > int val; > int c; >@@ -183,13 +189,9 @@ options(int cmdline) > break; > } > while ((c = *p++) != '\0') { >- if (c == 'c' && cmdline) { >- char *q; >- >- q = *argptr++; >- if (q == NULL || minusc != NULL) >- error("Bad -c option"); >- minusc = q; >+ if (val == 1 && c == 'c' && cmdline) { >+ /* command is after shell args*/ >+ minusc = empty; > } else if (c == 'o') { > minus_o(*argptr, val); > if (*argptr) >blob - 6c892026ec75fc6931ee0f9b76fed990c0da2551 >blob + 941d962e068d224ddea96e02a545a9713a539341 >--- bin/sh/tests/invocation/Makefile >+++ bin/sh/tests/invocation/Makefile >@@ -7,6 +7,7 @@ TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T} > ATF_TESTS_SH= functional_test > > ${PACKAGE}FILES+= sh-ac1.0 >+${PACKAGE}FILES+= sh-c-a1.0 > ${PACKAGE}FILES+= sh-c-missing1.0 > ${PACKAGE}FILES+= sh-c1.0 > ${PACKAGE}FILES+= sh-ca1.0 >blob - /dev/null >blob + 617f1b1bd98cb7090f9a387ff407f6bd4e55bd70 (mode 644) >--- /dev/null >+++ bin/sh/tests/invocation/sh-c-a1.0 >@@ -0,0 +1,6 @@ >+# Test that options after c are processed >+ >+case `${SH} -c -a 'echo $-:$0' moo` in >+*a*:moo) true ;; >+*) false ;; >+esac >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 278653
: 250294