This includes a fairly detailed test of various known shell bugs from the autoconf docs. The idea here is that if redo works on your system, you should be able to rely on a *good* shell to run your .do files; you shouldn't have to work around zillions of bugs like autoconf does.
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
import sys, os
|
|
|
|
def init(targets):
|
|
if not os.environ.get('REDO'):
|
|
# toplevel call to redo
|
|
exenames = [os.path.abspath(sys.argv[0]),
|
|
os.path.realpath(sys.argv[0])]
|
|
dirnames = [os.path.dirname(p) for p in exenames]
|
|
trynames = ([os.path.abspath(p+'/../lib/redo') for p in dirnames] +
|
|
[p+'/redo-sh' for p in dirnames] +
|
|
dirnames)
|
|
seen = {}
|
|
dirs = []
|
|
for k in trynames:
|
|
if not seen.get(k) and os.path.exists('%s/.' % k):
|
|
seen[k] = 1
|
|
dirs.append(k)
|
|
os.environ['PATH'] = ':'.join(dirs) + ':' + os.environ['PATH']
|
|
os.environ['REDO'] = os.path.abspath(sys.argv[0])
|
|
|
|
if not os.environ.get('REDO_BASE'):
|
|
base = os.path.commonprefix([os.path.abspath(os.path.dirname(t))
|
|
for t in targets] + [os.getcwd()])
|
|
bsplit = base.split('/')
|
|
for i in range(len(bsplit)-1, 0, -1):
|
|
newbase = '/'.join(bsplit[:i])
|
|
if os.path.exists(newbase + '/.redo'):
|
|
base = newbase
|
|
break
|
|
os.environ['REDO_BASE'] = base
|
|
os.environ['REDO_STARTDIR'] = os.getcwd()
|
|
|
|
import state
|
|
state.init()
|