Repository navigation
cli: add --dump-ast AST output mode - #824
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 041a6dc39c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return astDumpSource{}, exitCode, err | ||
| } | ||
|
|
||
| script, err := readASTDumpSessionScript(ctx, session.FileSystem(), session.Limits().MaxFileBytes, runtimeOpts.defaultWorkingDir(), parsed.ScriptPath) |
There was a problem hiding this comment.
Resolve AST file paths from the runtime session cwd
For --dump-ast on file inputs, relative script paths are resolved with runtimeOpts.defaultWorkingDir() instead of the runtime session’s actual working directory. This diverges whenever cli.Config.BaseOptions sets a custom working dir (for example via gbash.WithWorkingDir(...)), so --dump-ast script.sh can read the wrong file or fail with "No such file" even though normal execution in the same config can run it. The AST loader should derive path resolution from the session/runtime configuration rather than recomputing defaults from CLI flags only.
Useful? React with 👍 / 👎.
Summary
--dump-astto print the parsed shell AST as pretty-printed typed JSON without executing--detectas a--dump-astmodifier that chooses the parser variant from shebang first, then file extension, else bashgbashandgbash-extras, and document it in the README and SPECValidation
go test ./cli ./cmd/gbash ./contrib/extras/cmd/gbash-extrasmake lint