return "{self}/{path}"
end
+ # Convert the path (`self`) to a program name.
+ #
+ # Ensure the path (`self`) will be treated as-is by POSIX shells when it is
+ # used as a program name. In order to do that, prepend `./` if needed.
+ #
+ # assert "foo".to_program_name == "./foo"
+ # assert "/foo".to_program_name == "/foo"
+ # assert "".to_program_name == "./" # At least, your shell will detect the error.
+ fun to_program_name: String do
+ if self.has_prefix("/") then
+ return self
+ else
+ return "./{self}"
+ end
+ end
+
# Alias for `join_path`
#
# assert "hello" / "world" == "hello/world"
var res = sys.system(cmd)
var res2 = 0
if res == 0 then
- res2 = sys.system("./{file}.bin >>'{file}.out1' 2>&1 </dev/null")
+ res2 = sys.system("{file.to_program_name}.bin >>'{file}.out1' 2>&1 </dev/null")
end
var msg
if toolcontext.opt_noact.value then return
# execute
var file = test_file
- var res = sys.system("./{file}.bin > '{file}.out1' 2>&1 </dev/null")
+ var res = sys.system("{file.to_program_name}.bin > '{file}.out1' 2>&1 </dev/null")
var f = new IFStream.open("{file}.out1")
var msg = f.read_all
f.close