PsBash
0.15.4
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.4
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 Complete-BashBgJobsAtExit 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-EscapeSequences Find-JqBranchKeyword Find-JqKeyword Find-JqTopLevelChar Find-JqTopLevelStr Format-BashDate Format-BashSize Format-LsGrid Format-LsLine Get-BashFileInfo Get-BashItem Get-BashJobCount Get-BashLsProviderEntries Get-BashPlatform Get-BashText Get-BrowseDisplayProperties Get-BrowseTargetText Get-JqMatchingBracket Get-LsDisplayName Get-LsEntryFromFsi Get-LsEntryFromPsItem Initialize-BrowseAdapters Invoke-BashBg Invoke-BashFg Invoke-BashJobs Invoke-BashSed Invoke-BashGrep Invoke-BashWait Invoke-BashBind Invoke-BashCaller Invoke-BashDisown Invoke-BashEnable Invoke-BashLogout Invoke-BashSuspend Invoke-BrowseAction Invoke-BrowseCommand Invoke-BrowseInteractive Invoke-JqFilter Invoke-JqIf Invoke-JqRecurse Invoke-JqSelect Invoke-ProcessSub New-BashProcessSubPath Invoke-ProcessSubPipeline Invoke-ProcessSubString New-BashObject New-BrowseAction New-BrowseAdapter New-BrowseBinding New-BrowseSafetyPreview Register-BrowseAdapter Get-BrowseAdapter Unregister-BrowseAdapter New-FlagDefs Open-BashFileReader Read-BashFileBytes Read-BashFileLines Read-BashFileRaw Read-BashFileStreaming Register-BashCompletions Register-BashLsProvider Remove-BashBgFinished Remove-BashBgState Resolve-BashCommand Resolve-BashGlob Resolve-BrowseAdapter Resolve-JqDotPath Resolve-JqStringInterpolation Set-BashDisplayProperty Set-BashErrorMode Show-BashHelp Split-JqComma Split-JqPipe Test-BashHelpFlag Test-BrowseCommandRequiresConfirmation Write-BashBgSignalReport Write-BashError Write-BashFileRaw Write-BashFileText Write-BashHostStderr
PSEditions
Dependencies
This module has no dependencies.
Release Notes
v0.15.4: Embedding and fixes. An embedding host that runs several sessions in one process can lend a credential to ONE session (ShellSecrets.Register): $NAME, $env:NAME and printenv read it in that session only, a child program gets exactly the granted secrets (export grants nothing, NAME=v cmd grants it to that command, env -i gives it to nobody), and env, printenv, set, declare -p and Get-ChildItem Env: list it as NAME=‹secret›. ${a[@]:o:n} copies only the selected elements, parsed arithmetic is cached, the 100k loop-pass limit is gone (bash has none), and the host gives memory back after a command (400 small commands end at about 253 MB instead of 410 MB). A leading | (| cat, ! | cat) is a syntax error, as in bash. A socket-path override longer than sun_path is a clear error instead of a launcher crash. v0.15.3: Performance and embedding. A bash array that a script grows (a+=(x)) or writes by element (a[i]=v) is a persistent vector: append and element-write loops are linear instead of quadratic (40k appends: 14.5 s -> 1.0 s; 40k element writes: 91 s -> 1.9 s), ${#a[@]} no longer copies the array, and a subshell, function scope or background job still never sees another copy's writes. An embedding host can lend its terminal to the full-screen programs a session runs (vim, htop, less) instead of piping them. v0.15.2: Bash-compatibility fixes. On Windows a lowercase spelling of a reserved name (path, tmp, temp, home, os) is its own variable, as in bash; Windows spellings (windir, SystemRoot) list upper-cased as in Git Bash, and set -x prints the bash name. unset -n drops a nameref, unset reads clustered options (-vn, -nf) and --, a nameref or attribute declared in a subshell ends with it, and a nameref declared with no target is listed, takes its target from the first write (assignment, for, read, printf -v), is unbound under set -u, and becomes an array when one is assigned to it. fc -l ranges, fc -s and fc -e - re-run as bash 5.2 does, in the caller (return, break, local), and history takes -d ranges, -p expansion and -anrw; history modifiers chain (:s, :gs, :&). A quoted builtin name (local, export, eval, return) runs the builtin and skips any alias, and a quoted declaration builtin splits its words as bash does. A return inside a redirected group, loop, if or case leaves the function; a run-time local is always local. Bash text built at run time (eval, trap, a nested bash -c) never runs as PowerShell. Under set -e a redirect that cannot open its file ends the shell. bash FILE exits 127 when FILE is missing and 126 when it is a directory. Array writes in a pipe stage or command substitution are several times faster. Container setups for Windows (Nano Server, Server Core) and Linux in docker/, with a CI smoke test. sed, grep, expr and find share one GNU regex translator (sed: last-regex reuse, N line numbers, -f error lines, s/y escapes). $SECONDS counts from the shell start and honours assignment; && / || operands record PIPESTATUS. Hosts: on Linux a session's warm host no longer exits seconds after each command; nested and overflow commands run on warm slots, not fresh hosts; install drains old hosts once idle instead of killing a running command (host drain). v0.15.1: Bash-compatibility fixes. A pipe stage is a subshell: cd, source, set, umask and the other state builtins in it change nothing in the caller. Refused assignments (readonly, a[]=, circular nameref) drop the rest of the line as bash does, and end the shell under set -e or posix. local -a/-A and declare in a function make a local array; a callee's array write reaches the caller's local; a local's attributes and nameref are its frame's. Diagnostics name the script and line (t.sh: line N:) for refusals, bad subscripts, failglob, ambiguous redirects and arithmetic errors; an arithmetic error discards the line. A builtin given too many arguments drops the line; exec reads the stdin it inherits; a piped script (cat f | bash) is read from stdin; env -i no longer clears the host environment; time and timeout pass their pipe byte for byte; every command rejects an option it does not have; on Windows the output of a redirected nohup command run by the Git ls/sh reaches its file, and 2> truncates. v0.15.0: Bash-compatibility release (XFAIL marks in the bash spec suite 140 -> 79). BREAKING: paths a script sees use forward slashes on Windows ($PWD, ~, $HOME, mktemp, realpath print C:/x; input still accepts C:\x and /c/x); bash code no longer resolves PowerShell aliases (gci, iex, r are command not found, 127, unless a function or program has the name; use the full cmdlet name); a nested shell sees exported variables only (x=1; sh -c "echo $x" prints an empty line; use export; a plain prog still sees all). Background jobs: output streams as the job runs, in launch order, with bounded memory; a job reads its own copy of the variables; a job sleep counts from its &. New: kill -SIG $$ and signals sent to a shell pid reach its trap; hash keeps the bash table; BASH_LINENO; --rcfile; a session whose hosts are all busy runs the command on a private host (PSBASH_EXEC_OVERFLOW_MS). Fix: pasted Unicode quote and dash marks no longer break the emitted PowerShell; line tools join a piece without its newline into the next line (printf a | sed); a while-read pipe stage reads lines as they are written; set -e ends a failing pipe stage; exit, break and errexit stop at subshell boundaries; pipefail after && and ||; an assignment sets PIPESTATUS; stopping a child ends its whole process tree; a 2>&1 child keeps its write order; a nested bash streams and is never timed out; a record keeps its trailing empty lines; base64 and od stream endless input; /dev/* names are never opened as files; file redirects write as output is produced; readlink and realpath canonicalize like GNU; kill -l prints the bash signal table; {a,} is one word; command and nohup run #! scripts; command not found carries the bash line prefix. Builtins and variables: help, bind, caller, enable, disown, logout, suspend; PPID, SHLVL, SRANDOM, BASH_SUBSHELL, default IFS; exec N<>file read-write descriptors; a DEBUG trap set on one line fires. Commands: GNU option parsing for uname, shuf, id, ping and tee; seq, tr, touch and install operand errors; date MMDDhhmm; env -C runs pwd in DIR; mkdir dir/; kill -RTMIN+N; a #! script reads the exact bytes piped to it. macOS: scripts no longer die with exit 138 (SIGUSR1 is left to the .NET runtime); stat, signals and ioctl are decoded per OS and arch. Known issues: docs/known-issues.md. Older versions: 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.15.4 (current version) | 11 | 11/26/2026 |
| 0.15.3 | 13 | 11/26/2026 |
| 0.15.2 | 12 | 11/25/2026 |
| 0.15.1 | 23 | 11/22/2026 |
| 0.15.0 | 29 | 11/19/2026 |
| 0.14.5 | 18 | 11/15/2026 |
| 0.14.4 | 12 | 11/14/2026 |
| 0.14.3 | 8 | 11/13/2026 |
| 0.14.2 | 39 | 11/6/2026 |
| 0.14.1 | 12 | 11/6/2026 |
| 0.14.0 | 58 | 10/20/2026 |
| 0.13.0 | 17 | 10/19/2026 |
| 0.12.0 | 12 | 10/17/2026 |
| 0.11.6 | 12 | 10/16/2026 |
| 0.11.5 | 31 | 10/10/2026 |
| 0.11.4 | 8 | 10/9/2026 |
| 0.11.3 | 11 | 10/8/2026 |
| 0.11.2 | 17 | 10/5/2026 |
| 0.11.1 | 16 | 10/3/2026 |
| 0.11.0 | 9 | 10/2/2026 |
| 0.10.23 | 169 | 7/26/2026 |
| 0.10.22 | 28 | 7/18/2026 |
| 0.10.21 | 28 | 7/7/2026 |
| 0.10.20 | 18 | 7/2/2026 |
| 0.10.19 | 22 | 6/19/2026 |
| 0.10.18 | 10 | 6/19/2026 |
| 0.10.17 | 8 | 6/19/2026 |
| 0.10.16 | 11 | 6/19/2026 |
| 0.10.15 | 17 | 6/17/2026 |
| 0.10.14 | 11 | 6/16/2026 |
| 0.10.13 | 9 | 6/16/2026 |
| 0.10.12 | 14 | 6/13/2026 |
| 0.10.11 | 10 | 6/11/2026 |
| 0.10.9 | 6 | 6/11/2026 |
| 0.10.8 | 51 | 6/4/2026 |
| 0.10.7 | 17 | 6/3/2026 |
| 0.10.5 | 10 | 6/1/2026 |
| 0.10.4 | 7 | 5/29/2026 |
| 0.10.3 | 7 | 5/29/2026 |
| 0.10.2 | 6 | 5/29/2026 |
| 0.10.1 | 13 | 5/29/2026 |
| 0.10.0 | 7 | 5/29/2026 |
| 0.9.13 | 11 | 5/24/2026 |
| 0.9.11 | 19 | 5/22/2026 |
| 0.9.10 | 7 | 5/21/2026 |
| 0.9.9 | 7 | 5/21/2026 |
| 0.9.8 | 7 | 5/20/2026 |
| 0.8.20 | 21 | 4/22/2026 |
| 0.8.19 | 7 | 4/22/2026 |
| 0.8.18 | 7 | 4/22/2026 |
| 0.8.17 | 8 | 4/21/2026 |
| 0.8.16 | 8 | 4/21/2026 |
| 0.8.14 | 11 | 4/20/2026 |
| 0.8.12 | 8 | 4/16/2026 |
| 0.8.11 | 5 | 4/16/2026 |
| 0.8.10 | 15 | 4/15/2026 |
| 0.8.7 | 5 | 4/14/2026 |
| 0.8.6 | 6 | 4/14/2026 |
| 0.7.6 | 8 | 4/12/2026 |
| 0.7.5 | 6 | 4/12/2026 |
| 0.7.4 | 6 | 4/12/2026 |
| 0.7.3 | 8 | 4/10/2026 |
| 0.7.2 | 6 | 4/10/2026 |
| 0.7.1 | 7 | 4/10/2026 |
| 0.7.0 | 8 | 4/9/2026 |
| 0.4.0 | 16 | 4/5/2026 |
| 0.3.0 | 6 | 4/4/2026 |
| 0.2.0 | 352 | 4/3/2026 |
| 0.1.0 | 101 | 4/3/2026 |