Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update to latest version of composure.sh

this fixes a bug in draft() and improves performance in metafor()
and glossary()
  • Loading branch information...
commit a385e0f32e56438656c782b7931bbca7f91193d7 1 parent 2050274
@erichs erichs authored
Showing with 17 additions and 4 deletions.
  1. +17 −4 lib/composure.sh
View
21 lib/composure.sh
@@ -228,8 +228,21 @@ draft ()
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:]]*//')
@@ -252,13 +265,13 @@ glossary ()
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
}
@@ -281,8 +294,8 @@ metafor ()
# 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 ()
Please sign in to comment.
Something went wrong with that request. Please try again.