Today's shell script: prove

Ovid on 2006-12-07T10:41:52

At work, almost every single time I run the prove utility, I type prove -l t/. I got tired of typing that. The following shell script in my bin/ seems silly, but it's really scratched an itch:

#!/usr/local/bin/bash

case "$1" in
    "") /usr/local/bin/prove -l t/ ;; # no arguments
    * ) /usr/local/bin/prove $*    ;; # Pass 'em straight through
esac


case

Dom2 on 2006-12-07T22:05:48

Sorry, but I can't resist golfing^Wtinkering with shell scripts...

  #!/usr/local/bin/bash

  [ $# == 0 ] && set -- -l t/
  exec /usr/local/bin/prove "$@"

$# is $#ARGV, more or less. Also, it's always better to use "$@" instead of $* because one day, you'll feed that sucker a filename with a space in. And it won't break with the former.

-Dom

Re:case

Ovid on 2006-12-10T20:07:23

Thanks for the tip about "$@"!