apenwarr-redo/redo-ifcreate.py
Avery Pennarun 2a936a7574 Print a nicer error message when asked to build an empty string ('').
This happens sometimes, for example, if you do
	whatever | while read x; do
		redo-ifchange "$x"
	done
and the input contains blank lines.

We could ignore the request for blankness, but it seems like that
situation might indicate a more serious bug in your parser, so it's
probably better to just abort with a meaningful error.
2018-11-03 22:02:26 -04:00

22 lines
562 B
Python
Executable file

#!/usr/bin/env python
import sys, os
import vars, state
from log import err
try:
me = os.path.join(vars.STARTDIR,
os.path.join(vars.PWD, vars.TARGET))
f = state.File(name=me)
for t in sys.argv[1:]:
if not t:
err('cannot build the empty target ("").\n')
sys.exit(204)
if os.path.exists(t):
err('redo-ifcreate: error: %r already exists\n' % t)
sys.exit(1)
else:
f.add_dep('c', t)
state.commit()
except KeyboardInterrupt:
sys.exit(200)