There actually is an array in any POSIX shell. You get one array per file/function. It just feels bad to use it. You can abuse ‘set – 1 2 3 4’ to act as a proper array. You can then use ‘for’ without ‘in’ to iterate over it.
for i; do echo $i; done.
Use shift <number> to pop items off.
If I really have to use something more complex, I’ll reach for mkfifo instead so I can guarantee the data can only be consumed once without manipulating entries.
There actually is an array in any POSIX shell. You get one array per file/function. It just feels bad to use it. You can abuse ‘set – 1 2 3 4’ to act as a proper array. You can then use ‘for’ without ‘in’ to iterate over it.
for i; do echo $i; done.
Use shift <number> to pop items off.
If I really have to use something more complex, I’ll reach for mkfifo instead so I can guarantee the data can only be consumed once without manipulating entries.
Cool, good to know.