Merge branch 'master' into search-parent-dirs

* master:
  Fixed markdown errors in README - code samples now correctly formatted.
  Fix use of config.sh in example
  log.py, minimal/do: don't use ansi colour codes if $TERM is blank or 'dumb'
  Use named constants for terminal control codes.
  redo-sh: keep testing even after finding a 'good' shell.
  redo-sh.do: hide warning output from 'which' in some shells.
  redo-sh.do: wrap long lines.
  Handle .do files that start with "#!/" to specify an explicit interpreter.
  minimal/do: don't print an error on exit if we don't build anything.
  bash completions: also mark 'do' as a completable command.
  bash completions: work correctly when $cur is an empty string.
  bash completions: call redo-targets for a more complete list.
  bash completions: work correctly with subdirs, ie. 'redo t/<tab>'
  Sample bash completion rules for redo targets.
  minimal/do: faster deletion of stamp files.
  minimal/do: delete .tmp files if a build fails.
  minimal/do: use ".did" stamp files instead of empty target files.
  minimal/do: use posix shell features instead of dirname/basename.
  Automatically select a good shell instead of relying on /bin/sh.

Conflicts:
	t/clean.do
This commit is contained in:
Avery Pennarun 2011-01-15 15:56:43 -08:00
commit e98696caef
20 changed files with 525 additions and 89 deletions

View file

@ -144,6 +144,9 @@ class BuildJob:
if vars.VERBOSE: argv[1] += 'v'
if vars.XTRACE: argv[1] += 'x'
if vars.VERBOSE or vars.XTRACE: log_('\n')
firstline = open(os.path.join(dodir, dofile)).readline().strip()
if firstline.startswith('#!/'):
argv[0:2] = firstline[2:].split(' ')
log('%s\n' % _nice(t))
self.dodir = dodir
self.basename = basename
@ -216,7 +219,8 @@ class BuildJob:
after_t = _try_stat(t)
st1 = os.fstat(f.fileno())
st2 = _try_stat(self.tmpname2)
if after_t != before_t and not stat.S_ISDIR(after_t.st_mode):
if (after_t and after_t != before_t and
not stat.S_ISDIR(after_t.st_mode)):
err('%s modified %s directly!\n' % (self.argv[2], t))
err('...you should update $3 (a temp file) or stdout, not $1.\n')
rv = 206