I use Bash, but I have come to do something I don't see elsewhere much. I make a lot of use of functions and local variables. Basically any time I see a coherent string of commands whether it's a pipe or a set of logical checks, I name the operation and put it in a function. String values are 'returned' as echo/cat output and logical values are just returned normally.
Finally I write the real logic using these functions so that you can read the intent and only have to deal with shell syntax within each function. To someone unfamiliar with it, or to someone familiar enough with stream-of-consciousness scripts, this looks a little weird and perhaps even counter productive, but I've found it's much easier to deal with the total flow by breaking it down and naming each feature rather than merely breaking up the flow with long # comments. This doesn't address a lot of your concerns, but it certainly makes my life easier. It's a stylistic choice that may or may not be appropriate to your coding. If it helps, great: A sample: https://github.com/markllama/openshift-on-openstack/blob/master/fragments/infra-boot.sh - Mark On Fri, May 13, 2016 at 8:10 AM Mark McCullough <mark.mc...@gmail.com> wrote: > > On 2016-05-12, at 15:38 , Yves Dorfsman <y...@zioup.com> wrote: > > > A lot of people love to hate bash, and there are good reasons for it, but > it > seems that there isn’t an obvious replacement for it. > > > ksh93 is the obvious replacement. I always felt that ksh was intended to > be a scripting language, bash was intended to be an interactive language. > It’s just that over time, I found that ksh’s interactive capabilities > pulled me in more. > > > At some point it looked like perl was going to be it, then depending on the > local preferences some shops use either python or ruby, heavy JVM shop > often > use groovy, while more and more shops now even use js or go... > > I find bash (or any other UNIX shell) much more natural for simple > scripts, I > don't even mind all gotchas (set -e, super weak typing, every var is gobal, > etc..), but do hate how bad it is to manipulate data, and the difficulty to > organize code. > > > ksh has supported non-global vars for some time using typeset inside a > function declaration (using a different function declaration syntax than > used by old sh to avoid confusion). Support for much more complex > structures has been there for quite some years now, including a struct > concept. It also supports FPATH, so you can put your functions outside the > original file for better organization of your code and even code reuse. > > Discipline functions give some interesting possibilities for data > manipulation as well. > > > What do *you* use? Do you see any clear winner to replace it on the > horizon? > > > I see people so much rushing to the next new thing that a widely available > tool that’s been stable for years isn’t even allowed to be reviewed, > causing people to continue to suffer with the crappy tools. > > Me? I use ksh93 + awk. Once I learned that combination, I found that it > met almost all my standard needs. > > > ---- > "The speed of communications is wondrous to behold. It is also true that > speed can multiply the distribution of information that we know to be > untrue." Edward R Murrow (1964) > > Mark McCullough > mark.mc...@gmail.com > > > > > _______________________________________________ > Tech mailing list > Tech@lists.lopsa.org > https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech > This list provided by the League of Professional System Administrators > http://lopsa.org/ >
_______________________________________________ Tech mailing list Tech@lists.lopsa.org https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech This list provided by the League of Professional System Administrators http://lopsa.org/