Treating environment variables as Values (#497)

* Proof of concept treating env vars as Values

* Refactor env var collection and method name

* Remove unnecessary pub

* Move env translations into a new file

* Fix LS_COLORS to support any Value

* Fix spans during env var translation

* Add span to env var in cd

* Improve error diagnostics

* Fix non-string env vars failing string conversion

* Make PROMPT_COMMAND a Block instead of String

* Record host env vars to a fake file

This will give spans to env vars that would otherwise be without one.
Makes errors less confusing.

* Add 'env' command to list env vars

It will list also their values translated to strings

* Sort env command by name; Add env var type

* Remove obsolete test
This commit is contained in:
Jakub Žádník
2021-12-17 03:04:54 +02:00
committed by GitHub
parent 342584e5f8
commit 6a0f404558
20 changed files with 414 additions and 132 deletions

View File

@ -88,15 +88,8 @@ impl Command for Use {
// TODO: Add string conversions (e.g. int to string)
// TODO: Later expand env to take all Values
let val = if let Ok(s) =
eval_block(engine_state, stack, block, PipelineData::new(call.head))?
.into_value(Span::unknown())
.as_string()
{
s
} else {
return Err(ShellError::EnvVarNotAString(import_pattern.span()));
};
let val = eval_block(engine_state, stack, block, PipelineData::new(call.head))?
.into_value(Span::unknown());
stack.add_env_var(name, val);
}