mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
Shell: Do not strip glob base path when it was explicitly requested
Fixes #3544.
This commit is contained in:
parent
eb24603da0
commit
4c2f86c24f
1 changed files with 6 additions and 1 deletions
|
@ -195,8 +195,11 @@ Vector<StringView> Shell::split_path(const StringView& path)
|
||||||
|
|
||||||
Vector<String> Shell::expand_globs(const StringView& path, StringView base)
|
Vector<String> Shell::expand_globs(const StringView& path, StringView base)
|
||||||
{
|
{
|
||||||
if (path.starts_with('/'))
|
auto explicitly_set_base = false;
|
||||||
|
if (path.starts_with('/')) {
|
||||||
base = "/";
|
base = "/";
|
||||||
|
explicitly_set_base = true;
|
||||||
|
}
|
||||||
auto parts = split_path(path);
|
auto parts = split_path(path);
|
||||||
String base_string = base;
|
String base_string = base;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
@ -214,6 +217,8 @@ Vector<String> Shell::expand_globs(const StringView& path, StringView base)
|
||||||
|
|
||||||
auto results = expand_globs(move(parts), resolved_base);
|
auto results = expand_globs(move(parts), resolved_base);
|
||||||
|
|
||||||
|
if (explicitly_set_base && base == "/")
|
||||||
|
resolved_base = resolved_base.substring_view(1, resolved_base.length() - 1);
|
||||||
for (auto& entry : results) {
|
for (auto& entry : results) {
|
||||||
entry = entry.substring(resolved_base.length(), entry.length() - resolved_base.length());
|
entry = entry.substring(resolved_base.length(), entry.length() - resolved_base.length());
|
||||||
if (entry.is_empty())
|
if (entry.is_empty())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue