4 ms·
Scala does something similarly neat with using #| for piping system commands. Slash for Scala is not used by default though for path joining, but it can be by
by yareally 13y ago
Scala does something similarly neat with using #| for piping system commands.
Slash for Scala is not used by default though for path joining, but it can be by adding an implicit function:
implicit def slash(str: String) = new { def /(joinStr: String) = str + java.io.File.separatorChar + joinStr}
val joinedStr = "abc"/"def"/"ghi"
> joinedStr : java.lang.String = abc/def/ghi
Shell friendly syntax can be used for stdin/stdout in Scala as well (already in the stdlib with no implicits required):
#< Redirect STDIN
#> Redirect STDOUT
#>> Append to STDOUT
#&& Create an AND list
#!! Create an OR list
http://stackoverflow.com/questions/12772605/scala-shell-commands-with-pipe/12772628 http://stackoverflow.com/questions/12772605/scala-shell-comm...
http://alvinalexander.com/scala/scala-execute-exec-external-system-commands-in-scala http://alvinalexander.com/scala/scala-execute-exec-external-...
- d0mine 13y agoThere are Plumbum shell combinators in Python http://plumbum.readthedocs.org/en/latest/ http://plumbum.readthedocs.org/en/latest/
- voltagex_ 13y agoThere are a couple of modules that do this kind of thing but Plumbum looks interesting, particularly http://plumbum.readthedocs.org/en/latest/local_commands.html#import-hack http://plumbum.readthedocs.org/en/latest/local_commands.html... >from plumbum.cmd import cat >>cat('tmp.txt') #invokes cat tmp.txt on the system