[Bug 278653] sh: fix sh -c -e cmd as per POSIX

[email protected]
Newsgroups gmane.os.freebsd.devel.standards
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278653

            Bug ID: 278653
           Summary: sh: fix sh -c -e cmd as per POSIX
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: standards
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 250294
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=250294&action=edit
fix sh -c -e cmd as per POSIX

POSIX requires sh(1) to handle -c like an option that does not take an
argument. We already handle the special case of attached options after -c...

$ sh -ce 'echo hello world'
hello world

.. but these fail:

$ sh -c -e 'echo hello world'
echo hello world: -e: not found
$ sh -c -- 'echo hello world'
echo hello world: --: not found

NetBSD fixed this 21 years ago. With their fix:

$ sh -c -e 'echo hello world'
hello world
$ sh -c -- 'echo hello world'
hello world
$ sh -c -e 'echo hello; false; echo world'
hello

Patch attached. I also added a minimal regression test.
I have only tested this on 14-STABLE, but there are no relevant changes between
14-STABLE and 15-CURRENT in sh.

-- 
You are receiving this mail because:
You are the assignee for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.