M cmd/hare/plan.ha => cmd/hare/plan.ha +1 -1
@@ 261,7 261,7 @@ fn execute(
};
for (let i = 0z; i < len(plan.environ); i += 1) {
let e = plan.environ[i];
- exec::setenv(&cmd, e.0, e.1);
+ exec::setenv(&cmd, e.0, e.1)!;
};
const pipe = if (plan.progress.tty is io::file) {
M cmd/hare/release.ha => cmd/hare/release.ha +3 -3
@@ 287,7 287,7 @@ fn signtag(tmpdir: str, name: str, tag: str, key: str) (void | release_error) =
defer exec::kill(agent)!;
const addkey = exec::cmd("ssh-add", key)?;
- exec::setenv(&addkey, "SSH_AUTH_SOCK", socket);
+ exec::setenv(&addkey, "SSH_AUTH_SOCK", socket)!;
const addkey = exec::start(&addkey)?;
const addkey = exec::wait(&addkey)?;
exec::check(&addkey)?;
@@ 299,9 299,9 @@ fn signtag(tmpdir: str, name: str, tag: str, key: str) (void | release_error) =
const ssh = exec::cmd("ssh-keygen",
"-Y", "sign", "-f", key, "-n", "file")?;
const note = exec::cmd("git", "notes", "add", "-F", "-", tag)?;
- exec::setenv(¬e, "GIT_NOTES_REF", "refs/notes/signatures/tar.gz");
+ exec::setenv(¬e, "GIT_NOTES_REF", "refs/notes/signatures/tar.gz")!;
- exec::setenv(&ssh, "SSH_AUTH_SOCK", socket);
+ exec::setenv(&ssh, "SSH_AUTH_SOCK", socket)!;
// Squelch "Signing data on standard input" message
// TODO: It might be better to capture this and print it to stderr
// ourselves if ssh-keygen exits nonzero, so that the error details are
M cmd/haredoc/main.ha => cmd/haredoc/main.ha +1 -1
@@ 298,7 298,7 @@ fn init_tty(ctx: *context) io::handle = {
const pipe = exec::pipe();
exec::addfile(&pager, os::stdin_file, pipe.0);
- exec::setenv(&pager, "LESS", "FRX");
+ exec::setenv(&pager, "LESS", "FRX")!;
ctx.pager = exec::start(&pager)!;
return pipe.1;
};
M os/exec/cmd.ha => os/exec/cmd.ha +7 -5
@@ 94,18 94,20 @@ export fn clearenv(cmd: *command) void = {
// current process environment. The 'key' must be a valid environment variable
// name per POSIX definition 3.235. This includes underscores and alphanumeric
// ASCII characters, and cannot begin with a number.
-export fn setenv(cmd: *command, key: str, value: str) void = {
+export fn setenv(cmd: *command, key: str, value: str) (void | errors::invalid) = {
let iter = strings::iter(key);
for (let i = 0z; true; i += 1) match (strings::next(&iter)) {
case void =>
break;
case let r: rune =>
if (i == 0) {
- assert(r == '_' || ascii::isalpha(r),
- "Invalid environment variable");
+ if(!(r == '_' || ascii::isalpha(r))) {
+ return errors::invalid;
+ };
} else {
- assert(r == '_' || ascii::isalnum(r),
- "Invalid environment variable");
+ if(!(r == '_' || ascii::isalnum(r))) {
+ return errors::invalid;
+ };
};
};