On Fri, Mar 19, 2021 at 09:10:06PM -0400, Dale R. Worley wrote: > Alex fxmbsw7 Ratchev <fxmb...@gmail.com> writes: > > yea well it does wonders, however was looking for a way without spawning > > externals like gawk.. maybe in future there will be =) > > Traditionally, shell scripts depended on external binaries to do a lot > of the processing. At the least, what newer shells do with "{NNN..MMM}" > and "[[" used to be done by "seq" and "test" a/k/a "[". And what can be > done by the complex parameter expansions ${...%...} and ${...#...} was > done by "sed".
Partly true. seq(1) is a Linux thing, and was never part of any tradition, until Linux people started doing it. Of note, it does not exist on any other systems. Some BSDs have jot(1) which does a similar thing, though. Counting in POSIX sh involves a while loop, and i=$((i+1)). (Before POSIX, it involved using expr(1) for every increment, which is simply abominable.) test or [ has been a builtin in every common shell for ages. The days of shells without a builtin test command are long gone. The difference between [[ and test is not really significant, if you're using the operators that are shared between them (e.g. test -f "$f"). The % and # parameter expansions have been around since ksh88, and are standardized in POSIX. You may be thinking of ${var//old/new} which is not part of POSIX, and would definitely have been done in sed(1). While I'm nitpicking your details, you are correct about your overall point, which is that shells are designed to use external tools to get things done. There's certainly a large grey area of tasks that can be done by builtins or by external tools, of course, but beyond a certain point, trying to force a shell to act like a Real Programming Language is just not reasonable.