diff --git a/rc b/rc index b1d5f75..dfd4b2e 100644 --- a/rc +++ b/rc @@ -10,6 +10,15 @@ export PATH . "$TOOLSPATH"/qcd_function +function _self_update() { + touch "$TOOLSPATH"/.lastupdate + pushd "$TOOLSPATH" > /dev/null + hg pull -u 2>&1 > /dev/null + popd > /dev/null +} + +[[ "$1" = "-u" ]] && _self_update + # Update self weekly [[ -t 0 ]] || return [[ -t 1 ]] || return @@ -18,11 +27,6 @@ export PATH [[ -f "$TOOLSPATH"/.lastupdate ]] || return TOOLS_LASTUPDATE=$(( $( date +%s ) - $( stat -c %Y "$TOOLSPATH"/.lastupdate ) )) -[[ "$TOOLS_LASTUPDATE" -gt 604800 ]] && { - touch "$TOOLSPATH"/.lastupdate - pushd "$TOOLSPATH" > /dev/null - hg pull -u 2>&1 > /dev/null - popd > /dev/null -} +[[ "$TOOLS_LASTUPDATE" -gt 604800 ]] && _self_update unset TOOLS_LASTUPDATE - +unset -f _self_update