On Mon, Oct 21, 2024, at 4:23 PM, Zachary Santer wrote: > On Mon, Oct 21, 2024 at 11:53 AM Chet Ramey <chet.ra...@case.edu> wrote: >> >> On 10/21/24 9:54 AM, Robert Elz wrote: >> > From the earlier message (just replying to this one to get the >> > new Subject: which fits better)... >> > >> > zsan...@gmail.com said: >> > | I can work around function names needing to be valid shell 'name's by >> > >> > 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?
Yes. A shell is an "implementation", not an "application". https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap02.html#tag_02_01 https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap02.html#tag_02_02 > 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 Google uses default-mode bash almost exclusively, so their guide is not relevant to a discussion about POSIX mode. https://google.github.io/styleguide/shellguide.html#s1.1-which-shell-to-use > Koichi Murase's ble.sh has a bunch of function names with '/', '-', > '.', etc. in the names. > https://github.com/akinomyoga/ble.sh/ I wouldn't be surprised if POSIX mode broke ble.sh in a number of ways. Using interactive shells in POSIX mode is surely uncommon. > I've got some functions that look like I'm overloading the increment > operator in C++: > abc::++ () { ... } > xyz::++ () { ... } > ++ () { ... } > > Those functions spent some time as "increment"* before I realized I > could do that, and I couldn't resist the urge. > > So my script might violate POSIX [...] I don't mind my script > violating POSIX. It's probably not going to run in any other > shell than bash anyway. Yes, a script that uses those functions is nonconformant, but that only matters if you're aiming for conformance in the first place. > but POSIX allows shell implementations to work with those > function names anyway? Yes. -- vq