[personal profile] kpreid

I was working on some automated document generation, building the process, revising the input document, and checking the results, and got tired enough of typing "make output/foo.txt && open output/foo.txt" and then going back and editing that line when I wanted to check the PDF version etc. that I wrote a tool which I hope will have more general application as well. I called it “maken”:

#!/bin/sh
# Make files and view the results.
make "$@" && open "$@"

Or it could be generalized into being a combinator, running any two commands, rather than just make and open, specified as the first two arguments:

#!/bin/sh
ca="$1"
shift
cb="$1"
shift
"$ca" "$@" && "$cb" "$@"

(Which, for the Haskell folks, should be called &&&, except that that would be annoying to enter in the shell.)

(no subject)

Date: 2009-10-28 04:57 (UTC)
From: [identity profile] dougo.livejournal.com
You could also add "open" targets to the Makefile.

(no subject)

Date: 2009-10-28 11:46 (UTC)
From: [identity profile] kpreid.livejournal.com

Hm, I could. I had rejected that solution because I figured I'd need a target for each output type, but that's not true, is it (untested):

open-%: %
	open "$^"

On the other hand, this command works in any project, not just this one.