(32 lines)
1 #!/usr/bin/env nomsu -V7.0.02 ###3 This file defines some actions for running shell commands.5 external:6 (at $callsite =sh $cmd) means:7 $f = ($io.popen $cmd)8 $contents = ($f, read "*a")9 [$ok, $return_type, $return] = ($f, close)10 unless $ok:11 if ($return_type == "exit"):12 at $callsite fail13 "Command failure: Command `\($cmd)` failed with exit code \$return"14 ..else:15 at $callsite fail16 "Command failure: Command `\($cmd)` was terminated by signal \$return"18 return $contents20 (at $callsite sh> $cmd) means:21 [$ok, $return_type, $return] = ($os.execute $cmd)22 unless $ok:23 if ($return_type == "exit"):24 at $callsite fail25 "Command failure: Command `\($cmd)` failed with exit code \$return"26 ..else:27 at $callsite fail28 "Command failure: Command `\($cmd)` was terminated by signal \$return"30 ### Attach callsite information for better error reporting31 (=sh $cmd) compiles to \(at \("Text" tree with "\($cmd.source)") =sh \$cmd)32 (sh> $cmd) compiles to \(at \("Text" tree with "\($cmd.source)") sh> \$cmd)