update to latest version of composure.sh
this fixes a bug in draft() and improves performance in metafor() and glossary()pull/134/head
parent
205027491a
commit
a385e0f32e
|
|
@ -228,8 +228,21 @@ draft ()
|
||||||
return
|
return
|
||||||
fi
|
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
|
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
|
else
|
||||||
# parse command from history line number
|
# parse command from history line number
|
||||||
cmd=$(eval "history | grep '^[[:blank:]]*$num' | head -1" | sed 's/^[[:blank:][:digit:]]*//')
|
cmd=$(eval "history | grep '^[[:blank:]]*$num' | head -1" | sed 's/^[[:blank:][:digit:]]*//')
|
||||||
|
|
@ -252,13 +265,13 @@ glossary ()
|
||||||
typeset targetgroup=${1:-}
|
typeset targetgroup=${1:-}
|
||||||
|
|
||||||
for func in $(typeset_functions); do
|
for func in $(typeset_functions); do
|
||||||
typeset about="$(typeset -f $func | metafor about)"
|
|
||||||
if [ -n "$targetgroup" ]; then
|
if [ -n "$targetgroup" ]; then
|
||||||
typeset group="$(typeset -f $func | metafor group)"
|
typeset group="$(typeset -f $func | metafor group)"
|
||||||
if [ "$group" != "$targetgroup" ]; then
|
if [ "$group" != "$targetgroup" ]; then
|
||||||
continue # skip non-matching groups, if specified
|
continue # skip non-matching groups, if specified
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
typeset about="$(typeset -f $func | metafor about)"
|
||||||
letterpress "$about" $func
|
letterpress "$about" $func
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
@ -281,8 +294,8 @@ metafor ()
|
||||||
# this sed-fu is the retrieval half of the 'metadata' system:
|
# this sed-fu is the retrieval half of the 'metadata' system:
|
||||||
# 'grep' for the metadata keyword, and then parse/filter the matching line
|
# 'grep' for the metadata keyword, and then parse/filter the matching line
|
||||||
|
|
||||||
# strip ending ; # ignore thru keyword # print remainder # strip start/end quotes
|
# grep keyword # strip trailing '|"|; # ignore thru keyword and leading '|"
|
||||||
sed -n "s/;$//;s/^[ ]*$keyword \([^([].*\)*$/\1/p" | sed "s/^['\"]*//;s/['\"]*$//"
|
sed -n "/$keyword / s/['\";]*$//;s/^[ ]*$keyword ['\"]*\([^([].*\)*$/\1/p"
|
||||||
}
|
}
|
||||||
|
|
||||||
reference ()
|
reference ()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue