Groups | Search | Server Info | Login | Register
Groups > comp.unix.shell > #25102
| From | Helmut Waitzmann <nn.throttle@xoxy.net> |
|---|---|
| Newsgroups | comp.unix.shell |
| Subject | Re: Which shell and how to get started handling arguments |
| Date | 2024-04-16 22:23 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <83r0f59hv1.fsf@helmutwaitzmann.news.arcor.de> (permalink) |
| References | <uvj65n$9aep$1@dont-email.me> <slrnv1qb9c.1cbm.naddy@lorvorc.mips.inka.de> <831q76bao7.fsf@helmutwaitzmann.news.arcor.de> <20240415173857.41@kylheku.com> |
Kaz Kylheku <643-408-1753@kylheku.com>:
> On 2024-04-15, Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
>> Compare (using GNU ls) with Christians well‐behaving "ls":
>>
>>
>> touch -- foo -l
>>
>> $ ls foo -l
>> -rw------- 1 helmut helmut 0 Apr 15 15:28 foo
>
> touch deviates in the first place; omit the -- and you get
>
>
> $ touch foo -l
> touch: invalid option -- 'l'
>
> That's crazy. foo is a non-option argument, so the options
> have ended at that point.
>
Yes, that's the same problem like with GNU "ls". (I decided to
silently avoid it by making use of the end‐of‐option marker
without commenting it.)
> I see where it is documented in "2 Common options" (Coreutils
> manual):
>
>
> Normally options and operands can appear in any order, and
> programs act as if all the options appear before any operands.
> For example, ‘sort -r passwd -t :’ acts like ‘sort -r -t :
> passwd’, since ‘:’ is an option-argument of -t. However, if
> the POSIXLY_CORRECT environment variable is set, options must
> appear before operands, unless otherwise specified for a
> particular command.
>
If I understand the last sentence correctly, setting the
POSIXLY_CORRECT environment variable forces the GNU utilities to
stop option processing before the first non‐option argument
(i. e. an argument beginning not with a "-") as if that argument
had been preceded by the end‐of‐option argument "--".
> It is disingenous to call it "POSIXly correct", because in fact
> the POSIX rules are how everyone understands it and how other
> implementors of utilities implement it. (Does anyone else do
> this crazy thing?)
>
>
> If all the vendors feature a given extension, so that it is
> portable, but POSIX refuses to adopt it, then, sure: the mode
> which takes the extension away can be flippantly called "POSIXly
> correct".
>
Maybe my knowledge of the English language is not good enough to
understand you correctly. Under the premise, that the
POSIXLY_CORRECT environment variable has been set, do you see the
GNU utilities behaving in any different way from what is the
behavior specified by POSIX?
> Also the claim "options must appear before operands [in POSIX]"
> is misleading, because "must" is usually interpreted as an
> imposed requirement, which can be violated and diagnosed. But in
> fact it is *logically* impossible for options to appear
> elsewhere because arguments that look like options placed in the
> non-option part of the command line are operands. It's the
> logical "must", not the reuqirements "must".
>
The GNU manual does not say "in POSIX" but says "if the
POSIXLY_CORRECT environment variable is set", but otherwise I
agree with you. This is, why I recommend to not make use of the
GNU behavior of looking for options right of the first non‐option
operand when neither the end‐of‐option marker is used nor the
POSIXLY_CORRECT environment variable has been set, but rather
always put any options (if present) first, then – regardless of
whether any options are actually present – in any case supply the
end‐of‐option marker ("--") and finally any non‐option operands.
This way both, POSIX utilities and GNU utilities, will behave the
same, even, if the POSIXLY_CORRECT environment variable happens
not to be set.
Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar
Which shell and how to get started handling arguments James Harris <james.harris.1@gmail.com> - 2024-04-15 13:22 +0100
Re: Which shell and how to get started handling arguments Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-04-15 16:03 +0200
Re: Which shell and how to get started handling arguments Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-04-15 16:34 +0200
Re: Which shell and how to get started handling arguments Christian Weisgerber <naddy@mips.inka.de> - 2024-04-15 13:35 +0000
Re: Which shell and how to get started handling arguments Helmut Waitzmann <nn.throttle@xoxy.net> - 2024-04-15 23:03 +0200
Re: Which shell and how to get started handling arguments Kaz Kylheku <643-408-1753@kylheku.com> - 2024-04-16 01:14 +0000
Re: Which shell and how to get started handling arguments Helmut Waitzmann <nn.throttle@xoxy.net> - 2024-04-16 22:23 +0200
Re: Which shell and how to get started handling arguments Ben Bacarisse <ben.usenet@bsb.me.uk> - 2024-04-15 15:45 +0100
Re: Which shell and how to get started handling arguments Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-04-15 15:06 +0000
Re: Which shell and how to get started handling arguments Christian Weisgerber <naddy@mips.inka.de> - 2024-04-15 15:36 +0000
Re: Which shell and how to get started handling arguments gazelle@shell.xmission.com (Kenny McCormack) - 2024-04-15 17:38 +0000
Re: Which shell and how to get started handling arguments Kaz Kylheku <643-408-1753@kylheku.com> - 2024-04-15 17:57 +0000
Re: Which shell and how to get started handling arguments Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-04-15 20:37 +0000
Re: Which shell and how to get started handling arguments Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-15 14:31 -0700
Re: Which shell and how to get started handling arguments Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-04-16 10:19 +0200
Re: Which shell and how to get started handling arguments Christian Weisgerber <naddy@mips.inka.de> - 2024-04-16 11:11 +0000
Re: Which shell and how to get started handling arguments Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-16 11:54 -0700
Re: Which shell and how to get started handling arguments gazelle@shell.xmission.com (Kenny McCormack) - 2024-04-16 19:59 +0000
Re: Which shell and how to get started handling arguments Christian Weisgerber <naddy@mips.inka.de> - 2024-04-16 21:57 +0000
Re: Which shell and how to get started handling arguments Kaz Kylheku <643-408-1753@kylheku.com> - 2024-04-16 20:45 +0000
Re: Which shell and how to get started handling arguments Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-16 16:38 -0700
Re: Which shell and how to get started handling arguments Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-17 00:52 +0000
Re: Which shell and how to get started handling arguments gazelle@shell.xmission.com (Kenny McCormack) - 2024-04-17 09:02 +0000
Re: Which shell and how to get started handling arguments Christian Weisgerber <naddy@mips.inka.de> - 2024-04-17 14:23 +0000
Re: Which shell and how to get started handling arguments Helmut Waitzmann <nn.throttle@xoxy.net> - 2024-04-15 23:49 +0200
Re: Which shell and how to get started handling arguments Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-15 22:20 +0000
csiph-web