Not long ago I devised an enhanced command processor in shell script, and called it exec-cmd. It might be the shortest (60-70 line) most-handy utility I had written, although shell script line count is not the clearest indicator of complexity, considering much reference to external text-processing utilities.
I wanted something to
- Be less verbose than shell functions.
- Be more expressive than shell aliases.
- Provide less verbose aliases, defined together with the main function.
- Feature inline named parameters, without explicit declarations or additional variable setting.
- Automatically display appropriate hints for missing parameters. This was one of the key motivators. I can see a Lisp macro very natural to this purpose, unlike basic shell script, requiring an awkward wrapper (which exec-cmd essentially carries out).
- Enable the invocation of other defined routines.
- Encapsulate all routines in a command file external to the shell script configuration, with autocompletion support.
- Be immediately interpreted like an external script.
- Display command help from an optional help file.
The processor utilizes basic shell script with two specialized constructs:
- !!param to indicate an inline parameter.
- %self% to reference other command defined in the processor.
The above are reconfigurable either inside the executable or an external
I found exec-cmd perfect for small shell-like applications without having to declare functions, explicitly check for passed parameters, or create external scripts.
You can find a sample command file named commands in the repository, much of which contains routines I use on a daily basis.
Questions, comments? Connect.