Skip to content

Commit

Permalink
env: add -S/--split-string option
Browse files Browse the repository at this point in the history
Adopted from FreeBSD's env(1), useful for specifing multiple
parameters on a shebang (#!) script line, e.g:

   #!/usr/bin/env -S perl -w -T

Discussed in https://lists.gnu.org/r/coreutils/2018-04/msg00011.html

* src/env.c (valid_escape_sequence,escape_char,scan_varname,
  extract_varname,validate_split_str,build_argv,
  parse_split_string): New functions.
  (main): Process new option and call parse_split_string.
  (usage): Mention new option.
* tests/misc/env-S.pl: Test new option from the command line.
* tests/misc/env-S-script.sh: Test new option from shebang scripts.
* tests/local.mk (all_tests): Add new tests.
* man/env.x (OPTIONS): Show a brief example of -S usage and point to
the full documentation for more information.
* doc/coreutils.texi (env invocation): Detail usage of -S/--split-string
option.
* NEWS: Mention new option.
  • Loading branch information
agordon authored and pixelb committed Jun 21, 2018
1 parent a0118a7 commit 668306e
Show file tree
Hide file tree
Showing 8 changed files with 1,258 additions and 5 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Expand Up @@ -26,7 +26,7 @@ dircolors: H. Peter Anvin
dirname: David MacKenzie, Jim Meyering dirname: David MacKenzie, Jim Meyering
du: Torbjorn Granlund, David MacKenzie, Paul Eggert, Jim Meyering du: Torbjorn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
echo: Brian Fox, Chet Ramey echo: Brian Fox, Chet Ramey
env: Richard Mlynarik, David MacKenzie env: Richard Mlynarik, David MacKenzie, Assaf Gordon
expand: David MacKenzie expand: David MacKenzie
expr: Mike Parker, James Youngman, Paul Eggert expr: Mike Parker, James Youngman, Paul Eggert
factor: Paul Rubin, Torbjörn Granlund, Niels Möller factor: Paul Rubin, Torbjörn Granlund, Niels Möller
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -53,6 +53,10 @@ GNU coreutils NEWS -*- outline -*-
env supports a new -v/--debug option to show verbose information about env supports a new -v/--debug option to show verbose information about
each processing step. each processing step.


env supports a new -S/--split-string=S option to split a single argument
string into multiple arguments. Used to pass multiple arguments in scripts
(shebang lines).

md5sum accepts a new option: --zero (-z) to delimit the output lines with a md5sum accepts a new option: --zero (-z) to delimit the output lines with a
NUL instead of a newline character. This also disables file name escaping. NUL instead of a newline character. This also disables file name escaping.
This also applies to sha*sum and b2sum. This also applies to sha*sum and b2sum.
Expand Down

0 comments on commit 668306e

Please sign in to comment.