Soundness: Guillotine

submited by
Style Pass
2024-06-05 16:30:04

Guillotine makes it easy to work with shell processes in Scala, with simple interpolation-based definitions of commands, and type-based interpretation of their output. For example, a directory listing may be obtained with sh"ls $path".exec[List[String]]().

Guillotine is available as a binary for Scala 3.5.0-RC1 and later, from Maven Central. To include it in an sbt build, use the coordinates:

Shell commands are created using the sh"" interpolator, which will interpret (at compiletime) a command and its arguments, correctly interpreting single- and double-quoted arguments and escaped characters. Unclosed quotes will result in a compile error.

Substitutions of values of a variety of different types may be made into an sh interpolator, and may be read as either "single-argument" (such as String or Int) or "multi-argument" (such as List[Int] or Set[String]).

Multi-argument substitutions will be interpreted as multiple arguments to the shell command unless they are enclosed within quotes, in which case they will be interpreted as a space-separated string.

Leave a Comment
Related Posts