Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
franck-gaspoz opened this issue Feb 17, 2021 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@franck-gaspoz
Copy link
Member

franck-gaspoz commented Feb 17, 2021

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 franck-gaspoz added the bug Something isn't working label Feb 17, 2021
@franck-gaspoz franck-gaspoz added this to the milestone 1 milestone Feb 17, 2021
@franck-gaspoz franck-gaspoz self-assigned this Feb 17, 2021
@franck-gaspoz franck-gaspoz removed their assignment Feb 17, 2021
@franck-gaspoz franck-gaspoz added the good first issue Good for newcomers label Feb 17, 2021
@franck-gaspoz franck-gaspoz changed the title $_./ doesn't works ... others special vars with single car behind / also $_./ doesn't works ... others special vars with single car behind _. also Feb 18, 2021
@franck-gaspoz franck-gaspoz added the help wanted Extra attention is needed label Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant