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.
This commit is contained in:
parent
2023d36676
commit
2a936a7574
4 changed files with 12 additions and 2 deletions
|
|
@ -282,6 +282,10 @@ def main(targets, shouldbuildfunc):
|
||||||
seen = {}
|
seen = {}
|
||||||
lock = None
|
lock = None
|
||||||
for t in targets:
|
for t in targets:
|
||||||
|
if not t:
|
||||||
|
err('cannot build the empty target ("").\n')
|
||||||
|
retcode[0] = 204
|
||||||
|
break
|
||||||
assert(state.is_flushed())
|
assert(state.is_flushed())
|
||||||
if t in seen:
|
if t in seen:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ try:
|
||||||
os.path.join(vars.PWD, vars.TARGET))
|
os.path.join(vars.PWD, vars.TARGET))
|
||||||
f = state.File(name=me)
|
f = state.File(name=me)
|
||||||
for t in sys.argv[1:]:
|
for t in sys.argv[1:]:
|
||||||
|
if not t:
|
||||||
|
err('cannot build the empty target ("").\n')
|
||||||
|
sys.exit(204)
|
||||||
if os.path.exists(t):
|
if os.path.exists(t):
|
||||||
err('redo-ifcreate: error: %r already exists\n' % t)
|
err('redo-ifcreate: error: %r already exists\n' % t)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ if len(sys.argv[1:]) != 1:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
want = sys.argv[1]
|
want = sys.argv[1]
|
||||||
|
if not want:
|
||||||
|
err('cannot build the empty target ("").\n')
|
||||||
|
sys.exit(204)
|
||||||
|
|
||||||
abswant = os.path.abspath(want)
|
abswant = os.path.abspath(want)
|
||||||
for dodir,dofile,basedir,basename,ext in paths.possible_do_files(abswant):
|
for dodir,dofile,basedir,basename,ext in paths.possible_do_files(abswant):
|
||||||
dopath = os.path.join('/', dodir, dofile)
|
dopath = os.path.join('/', dodir, dofile)
|
||||||
|
|
|
||||||
3
state.py
3
state.py
|
|
@ -189,8 +189,7 @@ class File(object):
|
||||||
row = d.execute(q, l).fetchone()
|
row = d.execute(q, l).fetchone()
|
||||||
if not row:
|
if not row:
|
||||||
if not name:
|
if not name:
|
||||||
raise Exception('File with id=%r not found and '
|
raise Exception('No file with id=%r name=%r' % (id, name))
|
||||||
'name not given' % id)
|
|
||||||
try:
|
try:
|
||||||
_write('insert into Files (name) values (?)', [name])
|
_write('insert into Files (name) values (?)', [name])
|
||||||
except sqlite3.IntegrityError:
|
except sqlite3.IntegrityError:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue