GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Thursday 8 February 2007
simple script hack to run scala code

When I'm just playing around with some Scala code, but do have it compiled into a package (us.l6r.something...), there's an unfortunate infelicity in the way the scala (and, I assume, the java) command behaves. If I want to use filename completion, I end up typing

scala u<tab>l<tab>p<tab>P<tab>
and the tab-completer turns this interactively into
scala us/l6r/prx/PenroseHex
which is where the PenroseHex.class file lives. The unfortunate part is that the scala command does not accept a slash-separated list as a package ("no such file: us/l6r/prx/PenroseHex"). What my srun script does is to simply change the slashes into dots, and run the scala command on the result. In this case, it would run:
scala us.l6r.prx.PenroseHex
and then it all Just Works. Cool. I'm sure the java cognoscenti have had this sort of script for years, but anyway, here's mine. I call it srun:
#!/usr/bin/env zsh
rarg="$( echo $1 | sed 's,/,.,g' )"
echo scala "$rarg"
scala "$rarg"

Here's one of those cases where writing a weblog encourages me to learn more stuff. Turns out that zsh substitution can do what that sed command does. So, if you don't need the verbosity of the echo, you can shorten the script to
#!/usr/bin/env zsh 
scala ${1//\//.}
Oh, and I also discovered that in my case, with my current dearth of scala packages, I can type two fewer characters; just
scala u<tab><tab><tab>P<tab>
will still get me the right tab-completions. Wheee.
12:48:27 AM   comment/     


Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/3/1; 22:38:01 .
Click here to send an email to the editor of this weblog.

February 2007
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28      
Jan   Mar

Previous/Next