apenwarr-redo/bin/default.do
Avery Pennarun 0b648521fd Move setproctitle() stuff into title.py.
This removes another instance of magical code running at module import
time.  And the process title wasn't really part of the state database
anyway.

Unfortunately this uncovered a bug: the recent change to use
'python -S' makes it not find the setproctitle module if installed.

My goodness, I hate the horrible python easy_install module gunk that
makes startup linearly slower the more modules you have installed,
whether you import them or not, if you don't use -S.  But oh well,
we're stuck with it for now.
2018-12-05 02:28:34 -05:00

35 lines
844 B
Text

exec >&2
case $1 in
redo-sh)
redo-ifchange ../redo/sh
cat >$3 <<-EOF
#!/bin/sh
d=\$(dirname "\$0")/..
[ -x \$d/lib/redo/sh ] && exec \$d/lib/redo/sh "\$@"
[ -x \$d/redo/sh ] && exec \$d/redo/sh "\$@"
echo "\$0: fatal: can't find \$d/lib/redo/sh or \$d/redo/sh" >&2
exit 98
EOF
chmod a+x "$3"
;;
redo|redo-*)
redo-ifchange ../redo/whichpython
read py <../redo/whichpython
cmd=${1#redo-}
cat >$3 <<-EOF
#!$py
import sys, os;
exe = os.path.realpath(os.path.abspath(sys.argv[0]))
exedir = os.path.dirname(exe)
sys.path.insert(0, os.path.join(exedir, '../lib'))
sys.path.insert(0, os.path.join(exedir, '..'))
import redo.title
import redo.cmd_$cmd
redo.title.auto()
redo.cmd_$cmd.main()
EOF
chmod a+x "$3"
;;
*) echo "$0: don't know how to build '$1'" >&2; exit 99 ;;
esac