summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2009-11-13 15:13:01 -0800
committerKaz Kylheku <kaz@kylheku.com>2009-11-13 15:13:01 -0800
commit34020d9344dbce334486ea9c3f5babdc6fbcbe10 (patch)
treef63ccd35ab0f8b3303bd65f3eb22f9655aabdb49 /Makefile
parent95e59dd555a038fd6eb70bc38e4e921d811b1f49 (diff)
downloadtxr-34020d9344dbce334486ea9c3f5babdc6fbcbe10.tar.gz
txr-34020d9344dbce334486ea9c3f5babdc6fbcbe10.tar.bz2
txr-34020d9344dbce334486ea9c3f5babdc6fbcbe10.zip
Allow -c scripts to not have a trailing newline.
Test suite exercises -c now. txr.c (txr_main): If the script specified with -c is not terminated by a newline, just add a newline. On the shell command line, it's a nuisance to have to add the extra line before closing the quote. It's also awkward in scripting, because the shell (or at least Bash 3.0) does not produce a final terminating newline in command substitution syntax like -c "$(cat file)". The last newline in the file is trimmed, and has to be explicitly added in the script itself, which is wrong in the case when the file is empty.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile7
1 files changed, 6 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index a3389518..878ca04f 100644
--- a/Makefile
+++ b/Makefile
@@ -68,9 +68,14 @@ tests/001/%: TXR_ARGS := $(top_srcdir)/tests/001/data
tests/002/%: TXR_OPTS := -DTESTDIR=$(top_srcdir)/tests/002
tests/004/%: TXR_ARGS := -a 123 -b -c
+tests/002/%: TXR_SCRIPT_ON_CMDLINE := y
+
%.ok: %.txr
mkdir -p $(dir $@)
- $(PROG) $(TXR_DBG_OPTS) $(TXR_OPTS) $^ $(TXR_ARGS) > $(@:.ok=.out)
+ $(if $(TXR_SCRIPT_ON_CMDLINE),\
+ $(PROG) $(TXR_DBG_OPTS) $(TXR_OPTS) -c "$$(cat $^)" \
+ $(TXR_ARGS) > $(@:.ok=.out),\
+ $(PROG) $(TXR_DBG_OPTS) $(TXR_OPTS) $^ $(TXR_ARGS) > $(@:.ok=.out))
diff $(^:.txr=.expected) $(@:.ok=.out)
%.expected: %.txr