Skip to content
Permalink
Browse files

env: add -S/--split-string option

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 Apr 21, 2018
1 parent a0118a7 commit 668306ed86c8c79b0af0db8b9c882654ebb66db2
Showing with 1,258 additions and 5 deletions.
  1. +1 −1 AUTHORS
  2. +4 −0 NEWS
  3. +372 −0 doc/coreutils.texi
  4. +35 −0 man/env.x
  5. +431 −4 src/env.c
  6. +2 −0 tests/local.mk
  7. +141 −0 tests/misc/env-S-script.sh
  8. +272 −0 tests/misc/env-S.pl
@@ -26,7 +26,7 @@ dircolors: H. Peter Anvin
dirname: David MacKenzie, Jim Meyering
du: Torbjorn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
echo: Brian Fox, Chet Ramey
env: Richard Mlynarik, David MacKenzie
env: Richard Mlynarik, David MacKenzie, Assaf Gordon
expand: David MacKenzie
expr: Mike Parker, James Youngman, Paul Eggert
factor: Paul Rubin, Torbjörn Granlund, Niels Möller
4 NEWS
@@ -53,6 +53,10 @@ GNU coreutils NEWS -*- outline -*-
env supports a new -v/--debug option to show verbose information about
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
NUL instead of a newline character. This also disables file name escaping.
This also applies to sha*sum and b2sum.

0 comments on commit 668306e

Please sign in to comment.
You can’t perform that action at this time.