return
fi
+ # aliases bind tighter than function names, disallow them
+ if [ -n "$(type -a $func | grep 'is.*alias')" ]; then
+ printf '%s\n' "sorry, $(type -a $func). please choose another name."
+ return
+ fi
+
if [ -z "$num" ]; then
- cmd=$(fc -ln -1 | head -1 | sed 's/^[[:blank:]]*//')
+ # parse last command from fc output
+ # some versions of 'fix command, fc' need corrective lenses...
+ typeset myopic=$(fc -ln -1 | grep draft)
+ typeset lines=1
+ if [ -n "$myopic" ]; then
+ lines=2
+ fi
+ cmd=$(fc -ln -$lines | head -1 | sed 's/^[[:blank:]]*//')
else
# parse command from history line number
cmd=$(eval "history | grep '^[[:blank:]]*$num' | head -1" | sed 's/^[[:blank:][:digit:]]*//')
typeset targetgroup=${1:-}
for func in $(typeset_functions); do
- typeset about="$(typeset -f $func | metafor about)"
if [ -n "$targetgroup" ]; then
typeset group="$(typeset -f $func | metafor group)"
if [ "$group" != "$targetgroup" ]; then
continue # skip non-matching groups, if specified
fi
fi
+ typeset about="$(typeset -f $func | metafor about)"
letterpress "$about" $func
done
}
# this sed-fu is the retrieval half of the 'metadata' system:
# 'grep' for the metadata keyword, and then parse/filter the matching line
- # strip ending ; # ignore thru keyword # print remainder # strip start/end quotes
- sed -n "s/;$//;s/^[ ]*$keyword \([^([].*\)*$/\1/p" | sed "s/^['\"]*//;s/['\"]*$//"
+ # grep keyword # strip trailing '|"|; # ignore thru keyword and leading '|"
+ sed -n "/$keyword / s/['\";]*$//;s/^[ ]*$keyword ['\"]*\([^([].*\)*$/\1/p"
}
reference ()