m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

m4 newbie q: ifelse not operating based on the value of sysval


From: David Niklas
Subject: m4 newbie q: ifelse not operating based on the value of sysval
Date: Sat, 19 Nov 2022 21:42:07 -0500

Hello,

I know I could do this with bash, awk, and probably several other
languages, I wanted to use m4.

I was trying to do a basic "If the file is there then include it,"
directive with m4.

echo 'define(`mkv'\'', `ogg'\'')ifelse(`1'\'', syscmd(`test -f
f'\'')sysval, `-i'\'' f `-map 1'\'')dnl' | m4 -D f="$i" -

I expected m4 to check if the file exists, with test. Then, m4 would
output the expansion "-i FILENAME -map 1" if the file exists, and output
nothing, "", if the file does not exist.

As a bit of a bonus question, can I somehow tack a period onto the front
of the mkv macro expansion? That way, instead of matching "mkv", it would
match ".mkv".

Thanks,
David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]