Posted to tcl by aku at Wed Mar 02 17:00:24 GMT 2011view pretty
# -*- sh -*- function f_hilit () { sed \ -e 's|\*CURRENT\*| [01;37;41m*CURRENT* [00m|g' \ -e 's|\*MERGE\*| [01;34m*MERGE* [00m|g' \ -e 's|\*BRANCH\*| [01;32;40m*BRANCH* [00m|g' \ -e 's|\[\([0-9a-z]*\)\]|[ [05m\1 [00m]|g' } function f () { rm $$.* 2> /dev/null cmd="$1" shift case "$cmd" in ch) clear echo fossil extra > $$.extra for pattern in $(cat $HOME/.fossil.ignore 2>/dev/null) $$.* do grep -v "$pattern" $$.extra > $$.kept mv $$.kept $$.extra done sed < $$.extra -e 's|^|EXTRA |' echo rm $$.extra fossil changes ;; delta) fossil changes|grep EDITED|awk '{ print $2 }' > $$.edited if test "X$1" != "X" ; then grep "$1" $$.edited|xargs -n1 fossil gdiff else cat $$.edited|xargs -n1 fossil gdiff fi rm $$.edited ;; hi) clear echo fossil timeline $*|f_hilit ;; co) echo "$1" > $$.M; shift; eval fossil commit -M $$.M "$*"; rm $$.M ;; coe) echo '' > $$.M; echo '# Commit message' >> $$.M; fossil extra | sed -e 's|^|#EXTRA |' >> $$.M; echo '' >> $$.M; fossil changes | sed -e 's|^|#|' >> $$.M; echo; vi $$.M; grep -v '^#' $$.M > $$$.MF; eval fossil commit -M $$.MF "$*"; rm $$.M $$.MF ;; up) clear echo fossil update echo fossil timeline|f_hilit echo ;; help) clear echo fossil help $* echo ;; *) # BAD. Quoting broken. Rather, the $* needs some form of # quoting to protect arguments with spaces in them. A # simple "$*" however is not the right way of doing that. eval fossil "$cmd $*" ;; esac }
Comments
Posted by evilotto at Fri Mar 04 03:29:21 GMT 2011 [text] [code]
use "$@" to have the shell quote things with spaces properly