Prototype macro for Shell Commands

This is a prototype for a subroutine macro that allows KM users to access a shell command using a KM macro rather than needing to use "Execute Shell Script". It's for discussion purposes. It's not meant to be used in any application at this time since it has not been thoroughly tested. In this macro I did my best to place the qualifiers for the grep command as parameters for a KM subroutine. Coming up with a good mapping of a shell command's "qualifiers and parameters" to KM Subroutine Parameters was the most challenging part. There's more than one possible mapping.

I came up with an interesting way to use a KM loop to handle qualifiers without arguments and qualifiers with arguments. I liked this approach.

All criticism is welcome. This is just an idea for consideration and discussion. I think the shell commands that I would like to see adapted into wrappers like this are: awk, bc, cat, cmp, colrm, csplit, curl, cut, defaults, df, du, file, fmt, head, hexdump, jot, netstat, nl, nslookup, od, paste, ps, rev, say, sed, seq, sort, tail, textutil, touch, uniq, uname and maybe xargs. (For a laugh, I noticed that the "uptime" command has no qualifiers or parameters. That command would be really easy to implement.)

Bear in mind that KM already has some actions that are probably just wrappers to access shell commands. I would suggest that the "Speak Text" action is one such action, which is possibly mapped to the "say" shell command. (Or it might use an API, there's no way to tell.)

As it happens, roughly half of the parameters for the average shell command would be of no value to a KM subroutine as half of the parameters tend to be applicable only when the command is issued from a command line. For example, most shell commands have a "-h" qualifier, which would be of no use to a KM version of that command.

This will be my last macro contribution before I go on a vacation in a few days. I'm not sure when I'll be back. It could be a long time.

grep Macro (v11.0.1)

grep.kmmacros (29 KB)