From dd937d61020b1b7437d59b18017c557849898c65 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Mon, 22 Nov 2010 02:45:00 -0800 Subject: [PATCH] redo-if{change,create}: print a useful message if REDO isn't set. Again, I forgot to make vars.py not crash if the variables aren't set, so we can print a useful error message. But this time I have the right solution: vars.py will do the checking for itself, and abort with a nice message. --- redo-ifchange.py | 4 ---- redo-ifcreate.py | 4 ---- vars.py | 6 ++++++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/redo-ifchange.py b/redo-ifchange.py index f7cb474..15d418e 100755 --- a/redo-ifchange.py +++ b/redo-ifchange.py @@ -45,10 +45,6 @@ def should_build(t): return not state.isbuilt(t) and dirty_deps(t, depth = '') -if not vars.TARGET: - err('redo-ifchange: error: must be run from inside a .do\n') - sys.exit(100) - rv = 202 try: try: diff --git a/redo-ifcreate.py b/redo-ifcreate.py index 160fff5..2794888 100755 --- a/redo-ifcreate.py +++ b/redo-ifcreate.py @@ -4,10 +4,6 @@ import vars, state from helpers import err, mkdirp -if not vars.TARGET: - err('redo-ifcreate: error: must be run from inside a .do\n') - sys.exit(100) - try: for t in sys.argv[1:]: if os.path.exists(t): diff --git a/vars.py b/vars.py index e3f32cf..54421a0 100644 --- a/vars.py +++ b/vars.py @@ -1,6 +1,12 @@ import os import atoi +if not os.environ.get('REDO'): + import sys + sys.stderr.write('%s: error: must be run from inside a .do\n' + % sys.argv[0]) + sys.exit(100) + PWD = os.environ.get('REDO_PWD', '') TARGET = os.environ.get('REDO_TARGET', '') DEPTH = os.environ.get('REDO_DEPTH', '')