| 1 | import os |
| 2 | |
| 3 | // NOTE: `execve` executes a new child process, in place of the current process. |
| 4 | // Therefore, only the topmost example will be executed when it's not commented out. |
| 5 | fn main() { |
| 6 | // Passes only an array of args. |
| 7 | os.execve(os.find_abs_path_of_executable('ls')!, ['-lh', '-s'], [])! |
| 8 | |
| 9 | // Considers args that would need to be passed within quotes. E.g.: `bash -c "ls -lh"`. |
| 10 | os.execve(os.find_abs_path_of_executable('bash')!, ['-c', 'ls -lah -s'], [])! |
| 11 | |
| 12 | // Passes an environment variable that affects the commands output. |
| 13 | os.execve(os.find_abs_path_of_executable('man')!, ['true'], ['MANWIDTH=60'])! |
| 14 | } |
| 15 | |