Skip to content

Commit

Permalink
realpath: handle empty paths
Browse files Browse the repository at this point in the history
  • Loading branch information
q66 committed Sep 29, 2024
1 parent 91acaa6 commit e080732
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src.custom/realpath/realpath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ static bool do_realpath(fs::path sp, bool newl) {
fs::path np;
std::error_code ec{};
/* then do the actual resolution */
if (strip && sp.is_relative()) {
if (sp.empty()) {
/* empty paths should issue ENOENT regardless of strip, like gnu */
errno = ENOENT;
if (!quiet) {
warn("''");
}
return false;
} if (strip && sp.is_relative()) {
/* no symlinks are expanded + relative input */
np = (fs::current_path(ec) / sp).lexically_normal();
} else if (strip) {
Expand Down

0 comments on commit e080732

Please sign in to comment.