PsBash
0.15.2
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.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. v0.14.5: Bash-parity pass: 189 oils spec cases fixed (XFAIL 316 -> 127). Fix: "$@" inside a function reached a command as one joined word (cat "$@" with two files failed) and dash options passed to a function (f -i x) broke grep/head "$@". Fix: a stopped command no longer kills the shared host; a nested ps-bash joins its enclosing session instead of starting a second daemon; ps-bash host list, and host gc removes only orphaned hosts. New: fc, piped bash -i runs as an interactive session, history -a/-w/-r, PROMPT_COMMAND, \D{fmt} in prompts, compgen -X/-A user/-A command, set -v/-n, BASHOPTS, umask -p, mapfile -O, printf %(fmt)T honors TZ, LC_ALL=C counts bytes, kill/wait jobspecs, ulimit soft/hard limits, redirect target globs. Also: GLOBIGNORE, POSIX ERE in =~, octal and invalid arithmetic values, NUL bytes in $( ) and read, printf %q of invalid UTF-8, sed \xHH, cat /dev/zero, a script with a NUL byte is refused as binary, unterminated quotes are syntax errors, failglob and bad substitutions drop the rest of the line, aliases with here-docs, tilde and globstar inside braces. v0.14.4: Resource-leak pass. Fix: a mktemp file a long script still needed was deleted once any shell ran a process substitution five minutes later. Now removed instead of piling up: socket files left by killed hosts, old module extraction directories (about 5 MB per build, kept while any process uses them), and empty mktemp -d directories older than 10 days. A background-job spare host that failed to start is replaced at once. Fix: aliases in plain PowerShell with Import-Module PsBash ("Unable to find type"); $_ in and after a pipeline; exec {fd}>file allocates a descriptor and >&$fd writes to it; bash -i -c sets HISTFILE; a quoted ] does not close a glob bracket. v0.14.3: Bash-compatibility batch (about 140 fixes, checked against bash 5.2). New: chmod (octal and symbolic modes, -R -v -c -f), od, nohup for background processes that outlive the shell, symbolic umask modes, set -a / allexport, $SHELLOPTS, history in scripts; launcher -e, -u, -o and -O apply to the -c string. Fix: unquoted expansions glued to text split as bash splits them, in arguments, $(...), [ ] and extglob patterns; arrays (sparse slices, element initializers in declare/local, subscripts as words, associative key order); namerefs, unset and local scoping; exit and return statuses, errexit, the ERR trap and errtrace; return inside eval text, source searches PATH; exec on stdin/stdout/stderr and numbered descriptors on a simple command; [ ] and [[ ]] operand rules; redirects to /dev/stdout and /dev/stderr; pushd, popd and dirs; trap DEBUG, CDPATH, the time keyword. Fix: bash -c and bash script.sh run the host bash when no ps-bash launcher is installed beside an embedded module (Linux), and start in the shell directory, not the process directory. v0.14.2: New ExecutableLookup (PsBash.Core): one execvp-style PATH search shared by the interactive shell, test -x, traceroute, tab completion and embedders - directories and files without an execute bit are skipped, so a non-executable file earlier on PATH no longer shadows the real binary (was exit 13 permission denied). find no longer forks stat per entry on Linux/macOS (Owner/Group resolve lazily). 10 more Oils spec cases now pass. v0.14.1: Bash-compatibility batch (about 250 fixes, oracle-verified). New: set -x trace, wait -n, timeout command, local -n namerefs write through, typeset -n/+n, aliases expand at transpile time under expand_aliases, compgen -F/-C/-W/-A, ${v@a/K/k/A}, readonly arrays, terminal tab title follows the running command. Fix: dirs -c/-v/-p, ERR trap LINENO and errtrace. Fix: read (heredoc, -d, -N/-n/-t, REPLY, backslash-newline); parameter expansion (indirect ${!ref}, ${#a[i]}, case-modifying `${v^}`/`${v,,}` with patterns, ${@-w}, negative slices); arrays written in functions reach the caller, per-element operators, unset a[-1]; declare/typeset/readonly/local attributes and declare -p output; `[` / `[[` operand and grouping rules, integer-expression errors; arithmetic edge cases and failing (( )) status; trap signal specs and EXIT traps in subshells; set -e with missing commands (127) and set option handling; alias bodies run as bash, egrep/fgrep; brace and tilde expansion corners; printf 64-bit integers; PIPESTATUS, BASH_VERSINFO, FUNCNAME, LINENO; background jobs see loop variables; rm -rf of the current directory; scripts piped into bash/sh. Release: NuGet publish uses trusted publishing (OIDC). 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.2 (current version) | 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 |