Skip to content

Grep returns resolved target paths for symlinked directories #38582

Description

@remixz

Description

When grep searches a symlinked directory, its output contains the real target path instead of the requested symlink path.

This breaks subsequent tool calls when external_directory permissions allow the symlink path but not the underlying path. A read using the filename returned by grep is denied even though the original search was allowed.

Plugins

None

OpenCode version

Development version before 1e636f0f7

Steps to reproduce

  1. Create a file and symlinked directory:
mkdir -p /tmp/repro/real
printf 'CREATE TABLE business (id INTEGER);\n' > /tmp/repro/real/schema.sql
ln -s /tmp/repro/real /tmp/repro/db_schema
  1. Run grep with:
{
  "path": "/tmp/repro/db_schema",
  "include": "schema.sql",
  "pattern": "CREATE TABLE .*business"
}
  1. Observe that grep returns:
/tmp/repro/real/schema.sql

Expected:

/tmp/repro/db_schema/schema.sql

Screenshot and/or share link

N/A

Operating System

Linux (Modal sandbox)

Terminal

N/A

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions