Bug 211029 - Add warning about calling `system("-some-tool")` that fails (although it is a valid `sh` command)
Summary: Add warning about calling `system("-some-tool")` that fails (although it is a...
Status: NEW
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-04 13:08 UTC by Ciprian Dorin Craciun
Modified: 2021-01-04 15:51 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Ciprian Dorin Craciun 2021-01-04 13:08:28 UTC
First of all please note I've already reported this bug to the `glibc` maintainers:

  https://sourceware.org/bugzilla/show_bug.cgi?id=27143

Their response was (I'm pasting together multiple replies):

~~~~
Unfortunately, this bug is required by POSIX, which requires passing the string as an argument to the -c option of the shell.

[...]

POSIX specifies the exact value of the -c argument.

The manual pages are maintained as a separate project: https://www.kernel.org/doc/man-pages/
~~~~

Therefore I'm opening a feature request here for the `system(3)` man page.



As such may I suggest adding a note in the `bugs` section of the man page that states something on the lines:
~~~~
If the command starts with a hyphen (as in `-some-tool`), due to the way `system(3)` is implemented in `glibc` and the way `sh(1p)` interprets when invoked as `sh -c -some-tool`, such a command will fail with an undefined behaviour.

A simple workaround for such a situation is to always prefix your commands with a space when such a command would start with a hyphen.
~~~~
Comment 1 Ciprian Dorin Craciun 2021-01-04 15:51:36 UTC
OK, I've opened an issue on the POSIX bug tracker:

  https://www.austingroupbugs.net/view.php?id=1440

Note You need to log in before you can comment on or make changes to this bug.