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 eggs
legs legs
pegs pegs
jegs jeggings
banana pants

View File

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