coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: env: add -S option (split string for shebang lines in scripts)


From: Kaz Kylheku (Coreutils)
Subject: Re: env: add -S option (split string for shebang lines in scripts)
Date: Wed, 25 Apr 2018 20:19:32 -0700
User-agent: Roundcube Webmail/0.9.2

On 2018-04-24 22:09, Pádraig Brady wrote:
I was thinking that the explanation of -S in usage() would say something like:

  -S, --split-string=S  process and split S into separate arguments
used to pass multiple arguments on shebang lines

One little problem with this FreeBSD design is that in spite of
supporting variable substitution, it lacks the flexibility of
specifying where among those arguments the script name is inserted!

Say we have a "#!/usr/bin/env -S lang ..." script called "foo.lang".

Suppose we want it so that "lang -f foo.lang -x" is invoked, where
-f is the option to the lang interpreter telling it to read the
script file foo.lang, and -x is an option to the foo.lang script
itself.

It would be useful if the -S mechanism could indicate this insertion
of foo.lang into the middle of the arguments.

The variable expansion mechanism could do it. Suppose that a certain
reserved variable name like ${ENV_COMMAND} (not my actual suggestion)
expands to the name of the last argument received by env.

Furthermore, when env is asked to expands this variable one or more
times, it makes a note of this and then sets a flag which suppresses
the script name from appearing in its usual position at the end.

Then this is possible:

    #!/usr/bin/env -S lang -f ${ENV_COMMAND} -x





reply via email to

[Prev in Thread] Current Thread [Next in Thread]