PsBash
0.10.11
Real bash commands for PowerShell with typed objects. 76 commands (ls, grep, sort, awk, sed, jq, find, ps, du, tar, etc.) that accept real bash flags and return structured PowerShell objects while producing identical text output. Pipeline bridge pattern preserves typed objects through grep, sort, head, tail.
Minimum PowerShell version
7.0
Installation Options
Owners
Copyright
(c) Andy Brummer. All rights reserved.
Package Details
Author(s)
- Andy Brummer
Tags
bash linux cross-platform cli grep awk sed jq pipeline typed-objects powershell-module devops unix shell commands windows macos
Functions
Compare-Version Complete-BashBgJob ConvertFrom-AwkProgram ConvertFrom-BashArgs ConvertFrom-HumanNumeric ConvertFrom-MonthName ConvertFrom-SimpleYaml ConvertFrom-YamlValue ConvertTo-BrowseRow ConvertTo-JqJson ConvertTo-PermissionString ConvertTo-SimpleYaml Disable-BashHookPrompt Emit-BashLine Enable-BashHookPrompt Expand-AwkString Expand-EscapeSequences Find-JqBranchKeyword Find-JqKeyword Find-JqTopLevelChar Find-JqTopLevelStr Format-AwkPrintf Format-BashDate Format-BashSize Format-LsGrid Format-LsLine Format-PsAuxLine Format-PsCustomLine Get-BashBgRunspacePool Get-BashFileInfo Get-BashItem Get-BashLsProviderEntries Get-BashPlatform Get-BashText Get-BrowseDisplayProperties Get-BrowseTargetText Get-DotNetProcEntry Get-JqMatchingBracket Get-LinuxProcEntry Get-LsDisplayName Get-LsEntryFromFsi Get-LsEntryFromPsItem Initialize-BrowseAdapters Invoke-AwkAction Invoke-BashAwk Invoke-BashBackground Invoke-BashBg Invoke-BashEcho Invoke-BashFg Invoke-BashJobs Invoke-BashKill Invoke-BashRedirect Invoke-BashSed Invoke-BashWait Invoke-BrowseAction Invoke-BrowseCommand Invoke-BrowseInteractive Invoke-JqFilter Invoke-JqIf Invoke-JqRecurse Invoke-JqSelect Invoke-ProcessSub Invoke-ProcessSubPipeline Invoke-ProcessSubString New-BashObject New-BrowseAction New-BrowseAdapter New-BrowseBinding New-BrowseSafetyPreview New-FlagDefs Open-BashFileReader Read-AwkBlock Read-BashFileBytes Read-BashFileLines Read-BashFileRaw Read-BashFileStreaming Register-BashCompletions Register-BashLsProvider Resolve-AwkExpression Resolve-AwkStringFunc Resolve-BashGlob Resolve-BrowseAdapter Resolve-JqDotPath Resolve-JqStringInterpolation Set-BashDisplayProperty Set-BashErrorMode Show-BashHelp Split-AwkFields Split-AwkFuncArgs Split-AwkStatements Split-JqComma Split-JqPipe Test-AwkPattern Test-BashCondition Test-BashHelpFlag Test-BrowseCommandRequiresConfirmation Write-BashError Write-BashFileRaw Write-BashFileText Write-BashHostStderr
PSEditions
Dependencies
This module has no dependencies.
Release Notes
v0.10.11: jq operators and the v0.10.10 publish fix. jq gains the non-arithmetic operator set — sort, unique, reverse, min, max, first, last, flatten, sort_by(e), unique_by(e), group_by(e), to_entries, from_entries, has(k), @csv/@tsv/@base64/@base64d/@json, and string builtins join/split/startswith/endswith/ltrimstr/rtrimstr — plus binary arithmetic (+ - * / %) with jq type overloads and boolean and/or. v0.10.10 binaries failed to publish because a Pester test still asserted printf %s "first arg only"; printf now correctly recycles its format over multiple args (bash semantics), and the test was corrected. v0.10.10: Command flag-coverage sweep (prioritized by utility and complexity). Correctness fixes for wrong/destructive behavior: kill -0 was killing the process (now an existence probe); cut open ranges (-f2-) threw; env NAME=VAL cmd (run-a-command-with-modified-environment) was unimplemented; cp -p leaked as a filename operand; paste -d emitted a literal backslash-n; md5sum -b was treated as a filename; realpath -e was a no-op. New flag support across ~25 commands: cut -s/--output-delimiter; cp -a/-u; wc -m/-L; stat --format; touch -r; du --max-depth; tree --noreport/-f; sort -o; nl -w/-s/-v/-i/-n/-b; uniq -D; grep -f/--exclude-from; find -type l/-print; date format codes (%I %R %D %z %u ...) and -d @EPOCH; printf format recycling and %i/%u/%e/%g; ls --group-directories-first; rg -S/-s/-x (smart-case/line-regexp); jq add/tostring/tonumber/ascii_downcase/ascii_upcase; tar --strip-components/-O; gzip -t; md5sum/sha* -c (verify); join -a/-v/-j/-i; split -b/--additional-suffix; xargs -d. Each comes with regression tests. Still pending: jq operators (group_by, @csv, arithmetic) and awk control flow (if/for/while) are engine-level projects. v0.10.9: Interactive shell features and runtime bug fixes. (1) cd - returns to the previous directory ($OLDPWD) and echoes it like bash; every successful cd now records $OLDPWD, and cd - with no prior directory reports "cd: OLDPWD not set" instead of failing on an empty path. (2) Bash history expansion in the interactive shell: !! (previous command), !n / !-n (by session index), !str / !?str? (prefix / substring search), the !$ / !^ / !* word designators and :n suffixes, and ^old^new quick substitution; expansion is suppressed inside single quotes and after a backslash, leaving the ! negation operator untouched. (3) ln -sf no longer destroys a populated directory tree: when the link name is a real directory the link is created inside it (basename of the target) and -f only removes a file or symlink, matching GNU ln (the old code ran a recursive delete). (4) awk file-operand mode: awk '{...}' file.txt now reads the named file(s) instead of silently dropping the operand and reading nothing. (5) kill fixes: named-signal short forms (kill -KILL / -TERM / -SIGTERM pid) are honored, and the pid loop no longer collides with the read-only $PID automatic variable, which silently broke every kill. (6) Stale-host fix: the daemon build identity now folds the host binary file stamp, so a recompiled host (same version, new code) replaces a running daemon instead of being silently reused. (7) Docs: new Interactive Shell guide and a Windows coreutils (uutils) comparison. v0.10.8: Robustness and interactive performance. (1) Interactive typing latency: keystrokes echo before the history/flag prediction runs, and prediction is fully async/debounced so a busy or IO-bound system never stalls input (set PSBASH_NO_PREDICT to disable it); the prompt is now drawn before the runspace finishes starting (startup type-ahead). (2) Hash-based transpile cache: startup .sh scripts transpile once and are cached on disk by content hash, with an in-memory LRU for repeated longer commands. (3) Bash-tool dogfood fixes: if/while/until conditions now test the command EXIT CODE rather than its output, so "if grep -q ..." and "if ! cmd" branch correctly; [ ... ] / test are silent (no stray True/False on stdout); every command resets the exit code on success (a trailing pwd no longer reports a stale 127); piping into "while read" now feeds the loop body; /dev/null as a file operand is an empty file instead of a crash; "cp -rf" bundled short flags are honored; and rm -rf / cp / mv / find -delete clear the read-only attribute so they no longer fail partway on Windows .git and node_modules trees. (4) grep gained --include / --exclude / --exclude-dir, -L/--files-without-match, -x/--line-regexp, -s/--no-messages, and -P/--perl-regexp. (5) "<cmd> --version" now identifies ps-bash across all commands. (6) Internals: emitted PowerShell is built through one shared builder and destructive filesystem operations through shared OS helpers, eliminating a class of one-off seam bugs (e.g. a negated-condition that took the wrong branch). v0.10.7: Fix path and pipeline gaps that broke the Claude Code Bash tool on Windows. (1) Piping a compound command — a for/while/until loop, if, case, subshell, or brace group — into another command (e.g. "for f in a b; do echo $f; done | sort") emitted a bare PowerShell statement before the pipe, which PowerShell rejects with "An empty pipe element is not allowed". Such pipeline stages are now wrapped in & { ... } at any position. (2) Windows path mapping is centralized in one shared WindowsPath utility used by BOTH the transpiler and the runtime cmdlets, handling /c/.. (MSYS/git-bash), /mnt/c/.. (WSL), and c:/.. (native, any separator/case) variants. Unix-style drive paths in command operands and cd targets — previously only redirect targets — are now translated (cat /c/Users/x and cd /mnt/c/work no longer resolve against the current drive as C:\c\..). When PSBASH_UNIX_PATHS is set (the Claude Code / wrapper case) the transpiler rewrites them ahead of time; the runtime also normalizes them on Windows as a safety net for direct, non-wrapper use. v0.10.4: Fix two bash-tokenization gaps. (1) A # in the middle of a word was wrongly treated as a comment, so abc#def and URLs like http://x/p#section lost everything from the #. (2) Bracket/quote scanning was not quote-aware, so a ) inside a string closed a $(...) early and a $(...) inside double quotes terminated at the wrong quote — e.g. echo $(grep ")" f) and echo "$(echo "hi")" mangled. The lexer now uses one set of mutually-recursive, quote-aware region scanners, and the parser reuses them instead of its own duplicate copies. v0.10.3: Fix heredoc body corruption. A here-document body was rebuilt by space-joining lexer tokens, so punctuation was mangled (best-ranked (score-desc, newest-first) became best-ranked ( score-desc, newest-first )), runs of whitespace collapsed, and lines beginning with # were dropped as comments. This broke piping multi-line text (e.g. git commit messages) through ps-bash. Heredoc bodies are now sliced verbatim from the original source. v0.10.2: Interactive Ctrl-R history search now collapses duplicate command strings. History stores one row per invocation, so re-running the same command filled the reverse-i-search list with repeats; the search now shows one row per unique command, keeping the best-ranked (most recent / CWD-matching) occurrence. v0.10.1: Fix Claude Code Bash-tool integration. A multi-variable bare assignment in a && / || chain (e.g. the TEMP/TMP env-setup Claude Code prepends to every command) emitted [void]($env:A = ..; $env:B = ..), which PowerShell rejects ("Missing closing )") — so every Bash-tool command failed with "ps-bash: parse error". The emitter now uses [void]$(...) for multi-statement assignments. Regression coverage: BashTranspilerTests, ShellArgsTests, an end-to-end launcher test, and a PowerShell parse-oracle over the wrapper shapes. v0.10.0: Interactive shell features. AI command assist (Ctrl-^) turns a natural-language prompt into a reviewed shell command via an external AI CLI, with a dangerous-command safety classifier (now also flags Invoke-Expression / iex). New opt-in compact-output mode (--compact-output / PSBASH_COMPACT_OUTPUT) replaces raw output with a bounded digest for agent contexts. Completion parameter-value rows now split on the ASCII unit separator so ValidateSet values containing a pipe are no longer truncated. v0.9.13: Fix broken module install. Install-Module PsBash now bundles PsBash.Cmdlets.dll (and its PsBash.Transpiler.dll / Parlot.dll deps) so a plain Install-Module PsBash is self-contained. Previously the registered aliases (ls, cat, grep, ...) resolved to binary cmdlets that were never loaded ("Invoke-BashLs is not recognized"); the module now warns instead of failing silently if the binary companion is absent. v0.9.12: Interactive shell fixes. Auto-loadable PowerShell aliases (tnc, gip) now resolve in the host runspace, and the interactive line editor no longer redraws erratically after launching a node-based GUI CLI such as code. Full version history: https://github.com/standardbeagle/ps-bash/releases
FileList
- PsBash.nuspec
- BashFlagSpecs.json
- Parlot.dll
- PsBash.Cmdlets.dll
- PsBash.Format.ps1xml
- PsBash.Transpiler.dll
- PsBash.psd1
- PsBash.psm1
Version History
| Version | Downloads | Last updated |
|---|---|---|
| 0.10.11 (current version) | 4 | 6/11/2026 |
| 0.10.9 | 4 | 6/11/2026 |
| 0.10.8 | 48 | 6/4/2026 |
| 0.10.7 | 15 | 6/3/2026 |
| 0.10.5 | 8 | 6/1/2026 |
| 0.10.4 | 4 | 5/29/2026 |
| 0.10.3 | 3 | 5/29/2026 |
| 0.10.2 | 3 | 5/29/2026 |
| 0.10.1 | 4 | 5/29/2026 |
| 0.10.0 | 3 | 5/29/2026 |
| 0.9.13 | 7 | 5/24/2026 |
| 0.9.11 | 16 | 5/22/2026 |
| 0.9.10 | 4 | 5/21/2026 |
| 0.9.9 | 4 | 5/21/2026 |
| 0.9.8 | 5 | 5/20/2026 |
| 0.8.20 | 17 | 4/22/2026 |
| 0.8.19 | 4 | 4/22/2026 |
| 0.8.18 | 4 | 4/22/2026 |
| 0.8.17 | 3 | 4/21/2026 |
| 0.8.16 | 3 | 4/21/2026 |
| 0.8.14 | 9 | 4/20/2026 |
| 0.8.12 | 5 | 4/16/2026 |
| 0.8.11 | 3 | 4/16/2026 |
| 0.8.10 | 5 | 4/15/2026 |
| 0.8.7 | 3 | 4/14/2026 |
| 0.8.6 | 4 | 4/14/2026 |
| 0.7.6 | 5 | 4/12/2026 |
| 0.7.5 | 4 | 4/12/2026 |
| 0.7.4 | 3 | 4/12/2026 |
| 0.7.3 | 5 | 4/10/2026 |
| 0.7.2 | 3 | 4/10/2026 |
| 0.7.1 | 4 | 4/10/2026 |
| 0.7.0 | 5 | 4/9/2026 |
| 0.4.0 | 13 | 4/5/2026 |
| 0.3.0 | 4 | 4/4/2026 |
| 0.2.0 | 347 | 4/3/2026 |
| 0.1.0 | 96 | 4/3/2026 |