Using Shell Scripts with KM

Arguably, it takes a lot less research to learn shell commands, which are all documented in the man pages. As excellent as the KM Wiki is, it doesn't come close (and not much does) to the standard of man. And, of course, man man will teach one how to use a man effectively.

Additionally, recent exports of man documentation for most of the commonly used shells are also available online.

Additionally to that, there's the rest of the internet (Stack Overflow, Superuser, etc.)

I'm by no means saying one ought to prioritise shell over native KM, or any method over any other. It's just about the right tool, for the right job, and the more tools one has at one's disposal, the bigger the scope for doing a better job.

I think, mostly, I'm extremely surprised, given your educational background, that you would be so averse to the command line. It's like a hairdresser who hates getting their hair cut. That said, some doctors can't stand needles. And, while I have a couple of mathematics degrees, I don't like numbers much at all.

That's funny... My big blunder with bash was by way of a mistyped find command (albeit using it to perform an -exec command, namely, mv, on the returned files). But if you want a function that recurses through a folder tree and takes every file and moves it either up or down the tree to any depth depending on how many vowels it has in its filename, I can pass that along.

Again, quite surprising to hear this applied to yourself. To anyone not familiar with scripting, JavaScript can appear very alien in ways that can make it appear more opaque than shell scripts.

But, this is one (of a good few) advantages FiSH shell has over bash, in that it uses syntax that is less cryptic (there's no $(...), or ${-:@}, or if...fi, or !!).

Humans, by our very nature, depend on utilising knowledge and tools created by someone who knows more than us about it, so that we can benefit from their expertise. Otherwise, you would most definitely be wanting to put your computer in the bin, stop driving your car, and avoid looking up at the sky.

I think the sentiment behind this advice/recommendation is well-intentioned, but poorly-expressed and much too general, though it certainly has merit in specific situations when applied with a mixture of common sense (which isn't actually a thing, but people seem to believe it is), and a more well-defined boundary.

The same advice would stop others being able to use your JXA scripts, or ASObjC scripts, etc.

tell application "Finder" to tell a reference to the application files in ¬
    the entire contents of (the path to the applications folder) to ¬
    open

That's not a particularly damaging script, but it's a bloody annoying one, which I ran one time just to see what it would be like. Had to reboot. But damage can be achieved quite easily if you forget that System Events deletes things permanently, and accidentally do it with a whose filter and, say, miss out the word not or something.

Nope. Okay, you need someone to tell you there's a man command, but that's the same as needing someone to tell you there's a KM Wiki (although both the wiki and the man command are in the menu of the respective application). man -k <searchterm> is how I learned bash, although admittedly I enjoy the art of programming and learning a new language, whereas others would rather pluck out their eyelashes. But it's very doable.

Of course, I'm not saying you (or anyone) must now go and learn a shell language. It's just interesting to have heard your thoughts/preconceptions/anxieties, and it would be a shame if you were holding yourself back from doing something because of a disproportionate sense of caution (thought some caution is always advisable, as you said).


Anyway...

I actually intended just to post another solution to the problem, because I can't not supply an AppleScript for this:

property text item delimiters : linefeed

set input to system attribute "KMVAR_myvar" -- or one's preferred way to access a KM variable, e.g. `tell app "Keyboard Maestro Engine"...`
return the reverse of the input's paragraphs as text