fix(windows): correct shell flag for Git Bash / POSIX shells (fix #7) - #8
Merged
Merged
Conversation
Git Bash sets SHELL to bash.exe but shell_and_flag() used /C for every non-PowerShell shell. /C is only valid for cmd.exe; bash expects -c, which caused /C: Is a directory and exit 126 (fixes yvgude#7). - cmd.exe / cmd -> /C - powershell / pwsh -> -Command - bash, sh, zsh, fish, ... -> -c Adds windows_shell_flag_for_exe_basename + unit tests. Made-with: Cursor
yvgude
approved these changes
Mar 27, 2026
yvgude
left a comment
Owner
There was a problem hiding this comment.
Tested root cause analysis: detect_shell() returns SHELL env var (bash.exe on Git for Windows), but shell_and_flag() treated all non-PowerShell Windows shells as cmd.exe and passed /C. Fix is correct — proper detection of POSIX shells (bash/sh/zsh/fish) and assignment of -c flag. Unit tests are solid. Merging.
This was referenced Mar 27, 2026
yvgude
pushed a commit
that referenced
this pull request
Mar 27, 2026
yvgude
pushed a commit
that referenced
this pull request
Mar 27, 2026
- fix(#7/#11): Windows shell flag — detect POSIX shells (Git Bash) and use -c instead of /C (via PR #8, now merged from GitHub) - fix(#10): excluded_commands config option now actually enforced in shell::exec() — commands matching entries bypass compression entirely - feat(#13): lean-ctx-on / lean-ctx-off / lean-ctx-status shell functions added to init --global hook (bash/zsh/fish); LEAN_CTX_ENABLED env var controls default state - feat(#14): slow query log — commands exceeding slow_command_threshold_ms (default 5s) logged to ~/.lean-ctx/slow-commands.log; new lean-ctx slow-log [list|clear] command - feat(#15): lean-ctx update — self-update from GitHub Releases; detects platform, downloads archive, safely replaces binary; lean-ctx update --check for version check only Also synced docs PR #9 (README + session metrics mdc example).
yvgude
pushed a commit
that referenced
this pull request
Jun 21, 2026
Wire ten neuroscience/physics-motivated mechanisms to real hot-path call sites, deterministic by default (Rule #498 / prompt-cache intact), and make them provable via a new `lean-ctx introspect cognition` activity registry. - Phase 0: introspect registry + CLI + doctor; is_stochastic_enabled() gate - #2 time-variant Phi (EMA re-read); #1 Ebbinghaus decay + spacing effect - #3 Hebbian eviction + CLS consolidation (previously dead code, now wired) - #5 integration-aware Phi (greedy MMR) + content-based dedup fix - #6 global-workspace ignition; #4 learned field weights (bandit, argmax default) - #7 idle replay (sharp-wave-ripple); #9 FEP prefetch (active inference) - #8 immune detector vs context poisoning (coupled to workspace trust) - #10 QUBO selection spike behind LEAN_CTX_EXPERIMENTAL_QUBO (greedy stays default) Stochastic exploration gated behind LEAN_CTX_STOCHASTIC. Docs + CHANGELOG added. GitLab: epic root/lean-ctx#771 + foundation #772 + features #773-#782. 5653 lib tests green, zero clippy warnings. Co-authored-by: Cursor <cursoragent@cursor.com>
yvgude
added a commit
that referenced
this pull request
Jul 1, 2026
… wave 1)
Universal-provider-framework (enterprise#7): new [[proxy.providers]] registry
(id + wire shape + base_url + optional api_key_env) with /providers/{id}/...
routes — a new OpenAI/Anthropic/Gemini-compatible endpoint is pure config.
WireShape is deliberately separate from provider identity; gateway-held keys
replace caller credentials, callers authenticate with the Bearer token only.
Gateway bind (enterprise#8): proxy_bind_host + LEAN_CTX_PROXY_BIND_HOST
(default loopback, typo narrows to loopback); non-loopback bind hard-disables
the provider-key auth fallback and activates the proxy_allowed_hosts
Host-header allowlist (DNS-rebinding guard).
Security hardening M1 (enterprise#37): proxy-wide token-bucket rate limit
(proxy_max_rps; gateway default 50 rps, /health exempt) + negative tests for
host allowlist, bind fallback, credential stripping and burst limiting.
Refs: lean-ctx-enterprise#7 #8 #37 (backlog doc 13, wave 1)
Co-authored-by: Cursor <cursoragent@cursor.com>
yvgude
pushed a commit
that referenced
this pull request
Jul 29, 2026
Git Bash sets SHELL to bash.exe but shell_and_flag() used /C for every non-PowerShell shell. /C is only valid for cmd.exe; bash expects -c, which caused /C: Is a directory and exit 126 (fixes #7). - cmd.exe / cmd -> /C - powershell / pwsh -> -Command - bash, sh, zsh, fish, ... -> -c Adds windows_shell_flag_for_exe_basename + unit tests. Made-with: Cursor
yvgude
pushed a commit
that referenced
this pull request
Jul 29, 2026
yvgude
pushed a commit
that referenced
this pull request
Jul 29, 2026
- fix(#7/#11): Windows shell flag — detect POSIX shells (Git Bash) and use -c instead of /C (via PR #8, now merged from GitHub) - fix(#10): excluded_commands config option now actually enforced in shell::exec() — commands matching entries bypass compression entirely - feat(#13): lean-ctx-on / lean-ctx-off / lean-ctx-status shell functions added to init --global hook (bash/zsh/fish); LEAN_CTX_ENABLED env var controls default state - feat(#14): slow query log — commands exceeding slow_command_threshold_ms (default 5s) logged to ~/.lean-ctx/slow-commands.log; new lean-ctx slow-log [list|clear] command - feat(#15): lean-ctx update — self-update from GitHub Releases; detects platform, downloads archive, safely replaces binary; lean-ctx update --check for version check only Also synced docs PR #9 (README + session metrics mdc example).
yvgude
pushed a commit
that referenced
this pull request
Jul 29, 2026
Git Bash sets SHELL to bash.exe but shell_and_flag() used /C for every non-PowerShell shell. /C is only valid for cmd.exe; bash expects -c, which caused /C: Is a directory and exit 126 (fixes #7). - cmd.exe / cmd -> /C - powershell / pwsh -> -Command - bash, sh, zsh, fish, ... -> -c Adds windows_shell_flag_for_exe_basename + unit tests. Made-with: Cursor
yvgude
pushed a commit
that referenced
this pull request
Jul 29, 2026
yvgude
pushed a commit
that referenced
this pull request
Jul 29, 2026
- fix(#7/#11): Windows shell flag — detect POSIX shells (Git Bash) and use -c instead of /C (via PR #8, now merged from GitHub) - fix(#10): excluded_commands config option now actually enforced in shell::exec() — commands matching entries bypass compression entirely - feat(#13): lean-ctx-on / lean-ctx-off / lean-ctx-status shell functions added to init --global hook (bash/zsh/fish); LEAN_CTX_ENABLED env var controls default state - feat(#14): slow query log — commands exceeding slow_command_threshold_ms (default 5s) logged to ~/.lean-ctx/slow-commands.log; new lean-ctx slow-log [list|clear] command - feat(#15): lean-ctx update — self-update from GitHub Releases; detects platform, downloads archive, safely replaces binary; lean-ctx update --check for version check only Also synced docs PR #9 (README + session metrics mdc example).
yvgude
pushed a commit
that referenced
this pull request
Jul 29, 2026
Wire ten neuroscience/physics-motivated mechanisms to real hot-path call sites, deterministic by default (Rule #498 / prompt-cache intact), and make them provable via a new `lean-ctx introspect cognition` activity registry. - Phase 0: introspect registry + CLI + doctor; is_stochastic_enabled() gate - #2 time-variant Phi (EMA re-read); #1 Ebbinghaus decay + spacing effect - #3 Hebbian eviction + CLS consolidation (previously dead code, now wired) - #5 integration-aware Phi (greedy MMR) + content-based dedup fix - #6 global-workspace ignition; #4 learned field weights (bandit, argmax default) - #7 idle replay (sharp-wave-ripple); #9 FEP prefetch (active inference) - #8 immune detector vs context poisoning (coupled to workspace trust) - #10 QUBO selection spike behind LEAN_CTX_EXPERIMENTAL_QUBO (greedy stays default) Stochastic exploration gated behind LEAN_CTX_STOCHASTIC. Docs + CHANGELOG added. GitLab: epic root/lean-ctx#771 + foundation #772 + features #773-#782. 5653 lib tests green, zero clippy warnings. Co-authored-by: Cursor <cursoragent@cursor.com>
yvgude
added a commit
that referenced
this pull request
Jul 29, 2026
… wave 1)
Universal-provider-framework (enterprise#7): new [[proxy.providers]] registry
(id + wire shape + base_url + optional api_key_env) with /providers/{id}/...
routes — a new OpenAI/Anthropic/Gemini-compatible endpoint is pure config.
WireShape is deliberately separate from provider identity; gateway-held keys
replace caller credentials, callers authenticate with the Bearer token only.
Gateway bind (enterprise#8): proxy_bind_host + LEAN_CTX_PROXY_BIND_HOST
(default loopback, typo narrows to loopback); non-loopback bind hard-disables
the provider-key auth fallback and activates the proxy_allowed_hosts
Host-header allowlist (DNS-rebinding guard).
Security hardening M1 (enterprise#37): proxy-wide token-bucket rate limit
(proxy_max_rps; gateway default 50 rps, /health exempt) + negative tests for
host allowlist, bind fallback, credential stripping and burst limiting.
Refs: lean-ctx-enterprise#7 #8 #37 (backlog doc 13, wave 1)
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7.
Full reproduction and environment details: #7.
Problem
On Windows,
lean-ctx -c <command>failed with output like/C: Is a directoryand exit code 126 in Git Bash and whenSHELLpoints at a POSIX shell (e.g.bash.exe). Global shell hooks (alias git='lean-ctx -c git', etc.) were unusable in those environments.Root cause
detect_shell()returnsSHELLwhen set (e.g. Git for Windows sets it tobash.exe).shell_and_flag()treated every non–PowerShell executable on Windows ascmd.exe, passing/C. That switch is only valid forcmd.exe;bashexpects-c. Invoking bash with/Cleads to the MSYS-style error and 126.Solution
powershell/pwsh-Commandcmd.exe/cmd/Cbash,sh,zsh,fish, … (default)-cImplemented in
windows_shell_flag_for_exe_basename()and wired throughshell_and_flag()soexec,-cpassthrough, andctx_shell-style spawn paths stay consistent.Testing
windows_shell_flag_for_exe_basename(cmd, PowerShell,bash, etc.) inrust/src/shell.rscargo test: all tests passed in Dockerrust:1.88-bookworm(contributor host lacked MSVClink.exe; CI should confirm)lean-ctx -c "git --version"andlean-ctx -c "echo ok"should succeed after buildChecklist
shell.rsonly); no unrelated refactors-conly branch)