Source path including tilda (#3059)

* Use expand_path to handle the path including tilda

* Publish path::expand_path for using in nu-command

* cargo fmt

Co-authored-by: Wataru Yamaguchi <nagisamark2@gmail.com>
This commit is contained in:
WatsonThink
2021-02-15 17:41:49 +09:00
committed by GitHub
parent 48a90fea70
commit 0795d56c1c
3 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,7 @@ pub use lex::lexer::{lex, parse_block};
pub use lex::tokens::{LiteBlock, LiteCommand, LiteGroup, LitePipeline};
pub use parse::{classify_block, garbage, parse, parse_full_column_path, parse_math_expression};
pub use path::expand_ndots;
pub use path::expand_path;
pub use scope::ParserScope;
pub use shapes::shapes;
pub use signature::{Signature, SignatureRegistry};

View File

@ -1788,7 +1788,9 @@ fn parse_call(
)),
);
}
if let Ok(contents) = std::fs::read_to_string(&lite_cmd.parts[1].item) {
if let Ok(contents) =
std::fs::read_to_string(expand_path(&lite_cmd.parts[1].item).into_owned())
{
let _ = parse(&contents, 0, scope);
} else {
return (