I'm making a makefile and I'm working on a target with no dependencies that checks to see if a file named README exists in the current directory and if it does, read it using less or else exit quitely: give no errors whatsoever--the command to run the target should print nothing to console if this is the case.
I've tried a couple different ways but nothing really seems to work (PAGER is simply a var equal to less):
read :
ifneq ("$(wildcard README)","")
-@$(PAGER) README
endif
And also with this code
read :
-@for file in *;\
do \
if [ ${file} == "README" ]; then\
$(PAGER) "README" ;\
fi;\
done
With the first chunk I keep getting an error akin to /bin/sh: Syntax error: word unexpected (expecting ")") and for the life of me I just don't get what it's saying. I certainly don't think there's a syntax error, perhaps I'm misusing make.
For the latter code I get an unexpected operator error for the ==.
I've also tried simpler things like these two single liner solutions but get similar errors:
-@test -a README && less README
-@[ -a README ] && less README
Any help would be greatly appreciated.
EDIT: I was digging further and saw something promising and explicitly setting my shell to /bin/bash (SHELL := /bin/bash) yet no dice.
read:
@if [ -e README ]; then less README; fi