I am having trouble writing a Makefile that can determine what command to run based on who the user is.
Code:
bash-2.05b$ cat Makefile
NOTES_INSTALL_DIR = /tmp
install:
runner=`whoami` ; \
if test $$runner != "root" ; \
then \
echo "You are not root. Have password ready"; \
su -c "cp index.html bookmarks.html notes.css ${NOTES_INSTALL_DIR}"; \
else \
echo "You are root" ; \
cp index.html bookmarks.html notes.css ${NOTES_INSTALL_DIR}"; \
fi
bash-2.05b$ make install
runner=`whoami` ; \
if test $runner != "root" ; \
then \
echo "You are not root. Have password ready"; \
su -c "cp index.html bookmarks.html notes.css /tmp"; \
else \
echo "You are root" ; \
cp index.html bookmarks.html notes.css /tmp"; \
fi
/bin/sh: -c: line 1: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 2: syntax error: unexpected end of file
make: *** [install] Error 2
bash-2.05b$
Should that work ?