Reputation: 17323
My intent is to automate the compilation process in my workflow. I have a single Makefile
in the root directory and I find myself constantly typing in make
to see the result and then SIGTERM
to refresh (I'm running OS X 10.8.5). Whereas ideally, a bash script would listen for changes in the file, and automake when they are made, and then run the executable.
I have the following attempt at implementing a bash script.
#!/bin/bash
while true
do
ATIME=`stat library/grid.c | egrep -o -m 3 '"(.{20})"' | tail +4`
if [[ "$ATIME" != "$LTIME" ]]
then
echo "Running make..."
bash -e make; ./sheet
LTIME=$ATIME
fi
sleep 1
done
This results in the following errors
/usr/bin/make: /usr/bin/make: cannot execute binary file
./listener.sh: line 10: ./sheet: No such file or directory
How do I issue the command to make and run an executable in a new terminal window? The point of this is that I can keep my bash script running, listening for changes in the background, without the executable taking over.
Upvotes: 0
Views: 471
Reputation: 100986
It's not legal to run bash -e <cmd>
for any command, not just make. The argument given to bash
is expected to be a shell script, not a program.
I don't know why you're trying to use a shell like that; why not just run make
directly? But if you really want to run make
in bash you'll have to use the -c
flag.
If what you want to do is stop your script if make fails, then use:
make || exit 1
./sheet
If you want to keep going after an error but not run the command, then use:
make && ./sheet
Upvotes: 1