Skip to main content

Module shell_scan

Module shell_scan 

Source
Expand description

Just enough POSIX shell parsing for the PreToolUse rewrite to decide whether a command can run as { cmd; } | sqz compress.

A pipeline element runs in a subshell, so a builtin that changes shell state (cd, export, source, set, …) stops affecting the session once the command is grouped, and a background job keeps the pipe open until it exits. plan refuses those and anything it can’t follow, and accepts the rest: pipes, &&/||/; lists, loops, redirects, heredocs and comments. A leading cd DIR && stays outside the group.

Structs§

FlatCmd
One command of a flat list.
Plan
A command that can be piped through sqz.

Enums§

Shell
The user’s shell, for the expansions only zsh stops on.
Skip
Why a command is left alone.

Functions§

basename
A command’s name with its directory and any .exe suffix removed.
flat
Split command into simple commands joined by &&, ||, ; or newlines, marking the ones whose output can go through sqz on their own. Nothing is grouped, so builtins keep running in the shell itself and a permission checker sees the user’s commands as written.
flat_for
flat, unless piping its commands could run one the original never runs in shell.
plan
Decide whether, and how, command can be piped through sqz.