From 34020d9344dbce334486ea9c3f5babdc6fbcbe10 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 13 Nov 2009 15:13:01 -0800 Subject: 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. --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile') 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 -- cgit v1.2.3