idank / explainshell

match command-line arguments to their help text
GNU General Public License v3.0
13.17k stars 787 forks source link

Feature: Actually explain shell constructs #282

Open zachriggle opened 3 years ago

zachriggle commented 3 years ago

Hello @idank and thank you so much for making such a useful project!

One of its limitations is that, currently, it supports explaining command-line flags and arguments, from various things which have man-pages.

It does NOT support explaining basic shell contracts, let alone complicated shell constructs -- and is not opinionated on WHICH shell is being explained (sh/bash/dash/ksh/csh/zsh/etc.).

It would be nice to be able to paste in something like this:

if (( VARIABLE )); then

To inform me that the condition is taken IFF the variable $VARIABLE has been set.

This is distinct from e.g.

if [ -n "$VARIABLE" ]; then

Which takes the "true" condition only when $VARIABLE is defined AND has a nonzero content.

A similar shell construct might be

if [ -v VARIABLE ]; then

Which is identical to the first -- the -v flag returns true if its argument (VARIABLE) is a shell variable that is set at all --even if it's empty.

Do you have any plans to support something like this?

A stretch goal would be to support complicated shell expansion, e.g.

for k v in "${(@kv)zsh_associative_array}"; do

Which iterates over an associative array (in zsh, and possibly ksh) where k and v are set to the key and value of each entry.