[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: |
Assaf Gordon |
Subject: |
Re: env: add -S option (split string for shebang lines in scripts) |
Date: |
Sat, 5 May 2018 03:20:27 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
Hello,
Attached updated patch, two main improvements:
1. preserves empty arguments, e.g.
env -S echo "" bar
2. prints an error message on incorrect shebang usage:
$ cat xxx
#!src/env -v -S cat -n
$ ./xxx
src/env: possible incorrect usage of env in a script
Try 'src/env --help' for more information.
Item 2 is implemented in a separate patch (number 9) to ease review.
Of course the error message could be improved, as can the detection
if the exact circumstances, but I'm not sure it's warranted.
On 01/05/18 04:48 PM, Bernhard Voelker wrote:
On 05/01/2018 06:40 PM, Eric Blake wrote:
#!/usr/bin/env -S -P /usr/bin:/opt/bin:${PATH} perl
"env -Ppath" is not implemented in this patch, but if we think it's
worth while I'll add it in next patch.
So regarding -S, I'm currently a bit worried about whether a +413 lines
change to the 185 lines env.c source is really warranted ... but I have
to admit that I don't see how -S could be supported in an easier way).
This is certainly a judgment call (whether this feature is bloat or
useful enough).
The amount of code is the same ball-park number as the BSD
implementation (mine is slightly more verbose and with more comments):
https://github.com/freebsd/freebsd/blob/master/usr.bin/env/envopts.c
Binary-wise, these are the size differences with --debug and with -S:
$ size src/env.orig src/env.debug src/env.debug.s
text data bss dec hex filename
26521 1424 448 28393 6ee9 src/env.orig
27313 1456 480 29249 7241 src/env.debug
31027 1512 480 33019 80fb src/env.debug.s
regards,
- assaf
env-S-2018-05-05.patch.gz
Description: application/gzip