bug-bash
[Top][All Lists]
Advanced

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

Re: posix vs default mode nonsense


From: Chet Ramey
Subject: Re: posix vs default mode nonsense
Date: Tue, 22 Oct 2024 11:30:03 -0400
User-agent: Mozilla Thunderbird

On 10/21/24 4:23 PM, Zachary Santer wrote:
On Mon, Oct 21, 2024 at 11:50 AM Chet Ramey <chet.ramey@case.edu> wrote:

On 10/21/24 12:15 AM, Zachary Santer wrote:

The nontrivial stuff I do is still being run by bash 4.2 at the
moment, and I'm not willing to give up procsubs.

Probably something to take up with your distro (Red Hat/Centos, right?)

RHEL 7. Something more recent is coming ... eventually.

Love those end-of-support versions.


That one bash could easily fix if it wanted to, there's never been a
POSIX requirement that only "name"s can be used as function names.

No, the original 1992 standard required it:

"The function is named fname; it shall be a name (see 3.1.5)."

That changed to an application requirement in 2001.

Pardon my ignorance, but as an "application requirement," is that
saying what shell scripts are allowed to do, rather than what bash
itself is allowed to do? That's how I would interpret kre's quote from
the standard. Otherwise, it's contradicting itself.

Yes, now that it says it's an application requirement, the shell can
assume that applications understand they're going off into the wild
west if they use something that's not a `name'.

Lots of shells (yash, dash, ksh93, SVR4.2 sh, gwsh, bash-posix) make trying
to define a function with a name like `f::method' a syntax error. Others
(bash, mksh, netbsd sh, freebsd sh, 9th edition sh) accept it. It's best
not to use it if portability is a concern.

Don't know how much weight the Google Shell Style Guide carries here,
or with the Austin Group, but:
  If you’re writing a package, separate package names with :: [in function 
names].
https://google.github.io/styleguide/shellguide.html#function-names

Just fine if you use `bash', not `sh' or `bash -o posix'.

So my script might violate POSIX, but POSIX allows shell
implementations to work with those function names anyway? I don't mind
my script violating POSIX. It's probably not going to run in any other
shell than bash anyway.

Maybe it's time for bash-posix to accept the same namespace as bash, but
that won't help with the portability problems.


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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