diff --git a/doc_src/cmds/path.rst b/doc_src/cmds/path.rst index d264fb97e..fa823adb2 100644 --- a/doc_src/cmds/path.rst +++ b/doc_src/cmds/path.rst @@ -145,7 +145,7 @@ The available filters are: Note that the path needs to be *any* of the given types, but have *all* of the given permissions. The filter options can either be given as multiple options, or comma-separated - ``path filter -t dir,file`` or ``path filter --type dir --type file`` are equivalent. -And if your operating system doesn't support a "sticky" bit, checking for it will always be false, so no path will pass. +If your operating system doesn't support a "sticky" bit, that check will always be false, so no path will pass. With ``--invert``, the meaning of the filtering is inverted - any path that wouldn't pass (including by not existing) passes, and any path that would pass fails. diff --git a/src/builtin_path.cpp b/src/builtin_path.cpp index 526c8ee18..ab067a854 100644 --- a/src/builtin_path.cpp +++ b/src/builtin_path.cpp @@ -415,8 +415,7 @@ static bool filter_path(options_t opts, const wcstring &path) { bool type_ok = false; struct stat buf; if (opts.type & TYPE_LINK) { - auto lret = !lwstat(path, &buf); - type_ok = lret && S_ISLNK(buf.st_mode); + type_ok = !lwstat(path, &buf) && S_ISLNK(buf.st_mode); } auto ret = !wstat(path, &buf); @@ -513,11 +512,6 @@ static int path_extension(parser_t &parser, io_streams_t &streams, int argc, con if (!pos) continue; - // This ends up being empty if the filename ends with ".". - // That's arguably correct. - // - // So we print an empty string but return true, - // because there *is* an extension, it just happens to be empty. wcstring ext = arg->substr(*pos + 1); if (opts.quiet && !ext.empty()) { return STATUS_CMD_OK; @@ -607,7 +601,8 @@ static int path_filter(parser_t &parser, io_streams_t &streams, int argc, const // If we don't have filters, check if it exists. // (for match this is done by the glob already) if (!opts.have_type && !opts.have_perm) { - if (!(!waccess(*arg, F_OK) ^ opts.invert)) continue; + bool ok = !waccess(*arg, F_OK); + if (ok == opts.invert) continue; } path_out(streams, opts, *arg);