Orbital-Shell icon indicating copy to clipboard operation
Orbital-Shell copied to clipboard

$_./ doesn't works ... others special vars with single car behind _. also

Open franck-gaspoz opened this issue 3 years ago • 0 comments

was thinking of a default in variable name parser, but seems it is just a lake of variable name searching in namespaces, like if the _ namespace if never scanned by search var function. see the code:

OrbitalShell-Kernel/Component/Shell/Variable/Variables.cs

/// <summary>
/// search in variables the path according to these precedence rules:
/// - absolute path
/// - path related to Local
/// - path related to Env
/// - path related to Global
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public bool Get(string path, out object value, bool throwException = true)
{
    var r = _dataRegistry.Get(path, out value)
    || _dataRegistry.Get(Nsp(VariableNamespace.local, path), out value)
    || _dataRegistry.Get(Nsp(VariableNamespace.global, path), out value)
    || _dataRegistry.Get(Nsp(VariableNamespace.env, path), out value);
    if (!r && throwException)
        throw new VariablePathNotFoundException(path);
    return r;
}

there is no search in:

VariableNamespace._

what is strange is that search in absolute path failed for _.{..}

to reproduce:

> echo $_./

⚠️ the use of caracter '_' should be a source of councerns since it is also used as namespace separator encoding in Enums that define variables namespaces and names

franck-gaspoz avatar Feb 17 '21 23:02 franck-gaspoz