|
From: | Eric Blake |
Subject: | Re: new snapshot available: coreutils-8.29.57-2ed7c2.tar.xz |
Date: | Wed, 27 Jun 2018 06:55:39 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
On 06/27/2018 02:11 AM, Pádraig Brady wrote:
On OpenBSD 6.2/amd64, few test failures: FAIL: tests/misc/env seems like "env -" does not work. I will investigate further (perhaps I've broken something with the changes to the command-line processing?).
$ ./src/env - env: invalid option -- '-'Looks like the hack of searching for '-' option only works on some getopt implementations.
No big surprise there - I was actually impressed that it worked for glibc when I first proposed the hack. So it looks like BSD has an (undocumented?) extension that if '-' appears in shortopts, then it changes how a lone '-' is parsed?
We _could_ replace getopt() on BSDs to the gnulib version to ensure we get glibc behavior, no matter what; but that feels heavy-handed when we are already abusing an undocumented non-standard corner of the API merely for better diagnosis of poor usage.
-static char const shortopts[] = "+C:iS:u:v0 \t-"; +static char const shortopts[] = "+C:iS:u:v0 \t";static struct option const longopts[] ={ @@ -566,14 +566,12 @@ main (int argc, char **argv) break; case ' ': case '\t': - case '-': /* Space,tab,dash are undocumented options. Attempt to detect incorrect shebang usage with extraneous space, e.g.: #!/usr/bin/env -i command
The comment is now stale.On the bright side, removing '-' still preserves the best usage of the hack; after all, we added it to cover:
#!/bin/env -v -Swhere the program is parsing "-v -S' as a single option, and space/tab is indeed encountered as the next short option before the second '-' character.
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
[Prev in Thread] | Current Thread | [Next in Thread] |