hare

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

commit b130ed190a61b619975f39c86f70f862ab437d53
parent d18f3ec2103fed68810def03e43abf891e44ce3f
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 12 Mar 2021 12:19:42 -0500

os::exec: add setname

This overrides argv[0] for the subprocess

Diffstat:
Mos/exec/cmd.ha | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -35,6 +35,12 @@ export fn cmd(name: str, args: str...) (command | error) = { return cmd; }; +// Sets the 0th value of argv for this command. It is uncommon to need this. +export fn setname(cmd: *command, name: str) void = { + free(cmd.argv[0]); + cmd.argv[0] = name; +}; + // Frees state associated with a command. You only need to call this if you do // not execute the command with [exec] or [start]; in those cases the state is // cleaned up for you.