Re: The "asort" extension (Was: feature proposal: expand associative arrays in lexicographic order ...)
Zachary Santer <[email protected]>
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <CABkLJUJBPBy3AM6NU1ff_FqB1FV2K-VpgoXGO7MpgzXEwgK2yA@mail.gmail.com> |
On Tue, Aug 25, 2026 at 5:04 PM Greg Wooledge <[email protected]> wrote: > > On Tue, Aug 25, 2026 at 16:20:03 -0400, Zachary Santer wrote: > > > > The indexed array expands in index numerical order anywhere you expand > > it. The for loop just takes whatever you give it in the order you give > > it in. It doesn't have to be an array expansion at all. > > That sounds like a description of the shell's for command, not gawk's. Yeah, that's what it is. I may not have understood what Stan was getting at there, honestly. > Personally, I think we're getting close to the line between a shell > and a programming language. If your shell script needs to extract the > keys of an associative array in lexicographical order, then it might > be the case that your shell script really ought to be redone in a more > powerful programming language. This script is all about running commands and filtering their output through sed and awk. It makes sense as a bash script. If there's a more powerful programming language that can do the equivalent of ``` shopt -s lastpipe command-1 | command-2 | while read whatever; do [...] done ``` in some reasonable way, then count me in. As it is, what I've got works really well, as much as writing it definitely took a little creativity here and there. Eventually, it's going to gain a (probably Ruby) helper program to serve as a coprocess that maintains a persistent TCP connection and handles REST API interactions. I know better than to try doing that in bash. This is effectively replacing a bunch of Python that's served as a great example of what not to do. I'd like to think I'm helping to move the ball forward here, leveraging the experience of trying to do some fairly complicated stuff in bash.