Conversation
|
There will be a companion PR in |
|
The repo https://github.com/MatrixAI/js-exec still needs some work - lots of configuration needed - README, and permissions, CI integration into Gitlab. |
|
Yeah, I'm still in the middle of working on it. |
|
@tegefaulkes the For Unix compatibility you need to start with Example provided in C: #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[], char *envp[]) {
// Add or modify an environment variable
setenv("MY_ENV_VAR", "some_value", 1);
// Prepare arguments for execvp
char *new_argv[] = {"program_name", "arg1", "arg2", NULL};
// Execute the program with the modified environment
execvp(new_argv[0], new_argv);
// If execvp returns, it failed
perror("execvp");
return EXIT_FAILURE;
}However, since you're using rust, I'm sure there's equivalents for it. What's the difference between using: |
|
Have a look: https://chat.openai.com/share/e/9c9f1315-d600-49c4-91a1-667ecb8ca0cb Example with extern crate libc;
use libc::{execvp, setenv};
use std::ffi::CString;
use std::os::unix::ffi::OsStrExt;
use std::process;
fn main() {
// Set an environment variable
let key = CString::new("MY_VARIABLE").unwrap();
let value = CString::new("some_value").unwrap();
unsafe {
if setenv(key.as_ptr(), value.as_ptr(), 1) != 0 {
eprintln!("Failed to set environment variable");
process::exit(1);
}
}
// Prepare the arguments for execvp
let program = CString::new("/usr/bin/env").unwrap();
let args = [
CString::new("env").unwrap().as_ptr(), // argv[0], conventionally the program name
std::ptr::null(), // Arguments must be terminated by a NULL
];
// Execute the command, replacing the current process
unsafe {
execvp(program.as_ptr(), args.as_ptr());
// If execvp returns, it means an error occurred
eprintln!("Error executing execvp");
process::exit(1);
}
}Also I see alot of vestigial comments, can you clean up the code of js-exec and make sure errors are all handled. |
|
If uapi is better, you can use that but you'll need to figure out how to set the environment. https://stackoverflow.com/questions/59922661/why-doesnt-unistd-h-execvpe-work-on-macos |
|
I updated a bit of the repo configuration in https://github.com/MatrixAI/js-exec. The usage in Note that since on Windows it is expected to throw an exception, can you create a Also on Windows, to simulate the same behaviour, you'd need to be able to create a subprocess and detach it and then terminate the parent process. This can be put for a future issue to address, for now a standard childprocess can be done on Windows. Which means for now using this may be a bit inefficient on Windows. |
144af95 to
17dc0be
Compare
|
OK, so we need to add the following before we can
I also need to go back to the |
|
TODO:
|
|
One thing I'm concerned about is that I'm using two different format options.
Ideally I'd just have |
|
I'ts possible to modify the options that have already been set. within the constructor when creating the command we can access the options array with Note that while |
3d9286e to
f2a68eb
Compare
[cvi skip]
[ci skip]
[ci skip]
f2a68eb to
92be342
Compare
|
Re-based on staging and ready to merge. |
Hold up! Did you have a read about #31 (comment) - there's important differences between different terminal/shell environments. And also it's important to acknowledge what we mean by the Now if you're going to overload that option I need you to explain what Here's what I'm proposing.
The problem is that we may deal 3 different "shell" environments:
It is important to note that none of these variables should be auto exported without an additional flag being So... I think IF we cannot do that, then if you overload the |
|
So by default variables are only local to the shell. Then with an extra |
|
You might want to address the |
|
Make sure to test this on the windows and mac machines we got too! |

Description
This PR addresses adding the
secrets envcommand to the cliIssues Fixed
pk secrets envcommand for meeting Development Environment Usecase #31Tasks
Final checklist