set_cwd
fn set_cwd(string path) -> Result<unit, EnvError> Import
Source: use env::{set_cwd}; compiler/src/builtin_docs/env.hy Changes the current working directory of the whole process.
Relative paths opened later, and programs started with exec, use the
new directory. Returns Err(EnvError::Other) if path does not exist
or is not an accessible directory. Needs --allow-env.
Parameters#
| Name | Type |
|---|---|
path | string |
Returns#
Result<unit, EnvError>
Examples#
use env::{cwd, set_cwd};
use tests::assert;
let before = match cwd() { Result::Ok(d) => d, Result::Err(_) => "/" };
assert!(match set_cwd("/tmp") { Result::Ok(_) => true, Result::Err(_) => false });
let _ = set_cwd(before);
See also#
env::execargs: Returns the program’s command-line arguments, starting with the program name.var: Returns the value of the environment variablename.set_var: Sets the environment variablenametovaluefor this process.remove_var: Removes the environment variablenamefrom this process.cwd: Returns the current working directory as an absolute path.exit: Ends the process at once with exit statuscode.