Read argv files via readarray

This commit is contained in:
Dan Buch 2024-04-19 21:11:24 -04:00
parent 8ac30a239d
commit d2d54c12a8
Signed by: meatballhat
GPG Key ID: A12F782281063434
2 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,5 @@
eggs
legs
pegs
jegs
jeggings
banana pants

View File

@ -1,3 +1,5 @@
SHELL := /bin/bash
CFLAGS ?= -Wall -g
GDBRUN = gdb --batch --ex run --ex bt --ex q --args
BUILD_TARGETS = $(foreach ex,$(wildcard ex*.c),$(subst .c,,$(ex)))
@ -22,8 +24,8 @@ gtest:
printf '\ngYAY\n'
.gtest.%:
@test_argv=$$(cat .$*.argv 2>/dev/null || echo) && \
printf '\n==> %s\n' "$*" && $(GDBRUN) ./$*
@if test -f .$*.argv; then readarray -t test_argv <.$*.argv; fi && \
printf '\n==> %s\n' "$*" && $(GDBRUN) ./$* "$${test_argv[@]}"
.PHONY: test
test:
@ -31,5 +33,5 @@ test:
printf '\nYAY\n'
.test.%:
@test_argv=$$(cat .$*.argv 2>/dev/null || echo) && \
printf '\n==> %s\n' "$*" && ./$* $$test_argv
@if test -f .$*.argv; then readarray -t test_argv <.$*.argv; fi && \
printf '\n==> %s\n' "$*" && ./$* "$${test_argv[@]}"