Allow source to accept paths with emojis (#3939)

* Allow sourcing paths with emojis

* Add source command tests for emoji paths

* Fmt

* Disable source tests on Windows with illegal paths

* Test sourcing also ASCII and single-quoted paths
This commit is contained in:
Jakub Žádník
2021-08-19 10:06:18 +03:00
committed by GitHub
parent 6db5692be4
commit e11b400a75
3 changed files with 110 additions and 3 deletions

View File

@ -1889,9 +1889,20 @@ fn parse_call(
)),
);
}
if let Ok(contents) = std::fs::read_to_string(&expand_path(Cow::Borrowed(Path::new(
&lite_cmd.parts[1].item,
)))) {
let script_path = if let Some(ref positional_args) = internal_command.args.positional {
if let Expression::FilePath(ref p) = positional_args[0].expr {
p
} else {
Path::new(&lite_cmd.parts[1].item)
}
} else {
Path::new(&lite_cmd.parts[1].item)
};
if let Ok(contents) =
std::fs::read_to_string(&expand_path(Cow::Borrowed(Path::new(script_path))))
{
let _ = parse(&contents, 0, scope);
} else {
return (