#604

Globs and find don't descend through symlinked directories; find has no -L/-H and -regex isn't anchored

Openasafyishopened 14d ago

just-bash version

3.6.0

Reproduction

ln -s /w/real /w/link
echo /w/*/s.txt
find /w/link/ -maxdepth 1
find -L /w -name s.txt
find /w -regex '.*\.tx'

How you run it

import { Bash } from "just-bash";

const bash = new Bash({ files: { "/w/real/s.txt": "x\n", "/w/a.txt": "a\n" } });
const result = await bash.exec(script);

Expected behavior

bash and GNU find:

/w/link/s.txt /w/real/s.txt
/w/link/
/w/link/s.txt
/w/link/s.txt
/w/real/s.txt

The -regex line prints nothing, because -regex has to match the whole path.

Actual behavior

/w/real/s.txt
/w/link
/w/a.txt
/w/real/s.txt

with find: unknown predicate '-L' on stderr. So:

  • Globs: pathname expansion doesn't go through a symlinked directory.
  • find with a trailing slash: find DIR/ doesn't resolve a symlinked operand, although the trailing slash should.
  • -L and -H: find doesn't accept them.
  • -regex: it matches part of the path instead of the whole path.

We ran into the glob case through a basis -> <id> alias in our tree: echo /snapshots/*/basis/SNAPSHOT.md expands to nothing.

Environment

  • Runtime (Node, Bun, browser, CLI): Node
  • Runtime version: 26.8.2
  • Operating system: macOS 15
  • Bundler or framework, when relevant: none

Activity

0

No activity yet.