ref: e43ded677ea2a176f637ce90a6fa1b2ec038d09b
dir: /common.rc/
nl=' ' fn die{ >[1=2] echo $0: $* exit $"* } fn usage{ >[1=2] echo -n 'usage:' $usage exit 'usage' } # subst [-g] this [that] fn subst{ awk 'BEGIN{ global = 0 for(i = 1; ARGV[i] ~ /^-/; i++){ if(ARGV[i] == "-g") global = 1 ARGC-- } this = ARGV[i++]; ARGC-- that = ARGV[i++]; ARGC-- } { if(global) gsub(this, that) else sub(this, that) print }' $* } fn gitup{ gitroot=`{/$cputype/bin/git/conf -r >[2]/dev/null} if(~ $#gitroot 0) die 'not a git repository' gitrel=`{pwd | subst '^'$"gitroot'/?'} if(~ $#gitrel 0) gitrel='.' cd $gitroot startfs=() if(! test -e /mnt/git/ctl) startfs=true if(! grep -s '^repo '$gitroot'$' /mnt/git/ctl >[2]/dev/null) startfs=true if(~ $#startfs 1) /$cputype/bin/git/fs if not status='' }