mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 06:17:35 +00:00
Shell: Improve error propagation
This commit replaces 31 release_value_but_fixme_should_propagate_errors calls with TRYs. :^)
This commit is contained in:
parent
e89ba794d0
commit
e2f9011a8d
4 changed files with 40 additions and 45 deletions
|
@ -252,7 +252,7 @@ bool Shell::is_glob(StringView s)
|
|||
return false;
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> Shell::expand_globs(StringView path, StringView base)
|
||||
ErrorOr<Vector<DeprecatedString>> Shell::expand_globs(StringView path, StringView base)
|
||||
{
|
||||
auto explicitly_set_base = false;
|
||||
if (path.starts_with('/')) {
|
||||
|
@ -261,15 +261,10 @@ Vector<DeprecatedString> Shell::expand_globs(StringView path, StringView base)
|
|||
}
|
||||
|
||||
auto parts = path.split_view('/', SplitBehavior::KeepTrailingSeparator);
|
||||
DeprecatedString base_string = base;
|
||||
struct stat statbuf;
|
||||
if (lstat(base_string.characters(), &statbuf) < 0) {
|
||||
perror("lstat");
|
||||
return {};
|
||||
}
|
||||
struct stat statbuf = TRY(Core::System::lstat(base));
|
||||
|
||||
StringBuilder resolved_base_path_builder;
|
||||
resolved_base_path_builder.append(FileSystem::real_path(base).release_value_but_fixme_should_propagate_errors());
|
||||
resolved_base_path_builder.append(TRY(FileSystem::real_path(base)));
|
||||
if (S_ISDIR(statbuf.st_mode))
|
||||
resolved_base_path_builder.append('/');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue