hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

platform_cmd.ha (545B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use io;
      5 use os;
      6 use strings;
      7 
      8 export type platform_cmd = io::file;
      9 
     10 // Same as [[cmd]] except that executable file is determined by [[io::file]].
     11 // This function is not portable.
     12 export fn cmdfile(file: io::file, name: str, args: str...) command = {
     13 	let cmd = command {
     14 		platform = file,
     15 		argv = alloc([], len(args) + 1),
     16 		env = strings::dupall(os::getenvs()),
     17 		files = [],
     18 		dir = "",
     19 	};
     20 	append(cmd.argv, name);
     21 	append(cmd.argv, args...);
     22 	return cmd;
     23 };