PsBash

0.15.0

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

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name PsBash

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name PsBash

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

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-BashLsProviderEntries Get-BashPlatform Get-BashText Get-BrowseDisplayProperties Get-BrowseTargetText Get-JqMatchingBracket Get-LsDisplayName Get-LsEntryFromFsi Get-LsEntryFromPsItem Initialize-BrowseAdapters Invoke-BashBackground 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

Core

Dependencies

This module has no dependencies.

Release Notes

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). v0.14.0: Remote sessions. New: ps-bash session attach NAME gives a reattachable terminal (tmux-style) - a detached broker owns a PTY and the interactive shell, so the shell and its screen outlive the client; Ctrl-] d detaches, a new client gets the last 1 MiB of output replayed, several clients can attach (--read-only to watch), and session stop ends it. Remote use is ssh -t host ps-bash session attach NAME. Works on Linux, macOS and Windows (ConPTY); the wire protocol is documented in docs/sessions.md. Named sessions (PSBASH_SESSION=NAME) are now stateful by default: variables, cd and functions persist between commands in one pinned runspace (--stateless restores a fresh runspace per command); session list shows each mode. Changed: the Windows named-pipe transport is removed; AF_UNIX sockets are the only transport (a socket path over the OS limit now fails with a message naming TMPDIR). Fix: a shell started under a Windows pseudoconsole no longer inherits the parent redirected stdio (it read EOF and exited with no prompt), so PSBASH_PTY=1 works when ps-bash is launched from a pipe-driven parent. v0.13.0: Release integrity and safety. SECURITY: tar extraction refuses to write through an existing symlink or junction below the destination (it could escape the directory and still report success). New: named durable sessions - ps-bash session start|list|status|stop NAME plus PSBASH_SESSION=NAME give a host that outlives its launchers and runs concurrently with other sessions (docs/sessions.md). New: history lists entries, history -d ID deletes one, history -c erases all (secure delete, WAL truncate, VACUUM); a line starting with a space, or any line while PSBASH_HISTORY_PRIVATE=1, is never recorded; an unopenable history DB degrades to in-memory with a warning. Fix: install.sh and install.ps1 install the complete package (host and runtime files), smoke-test a real command before switching, keep the previous version for rollback, and name an unsupported platform. Release pipeline: binaries are built from one pinned commit, smoke-tested, and published only after the tests pass; dry-run mode rehearses a branch. Test harness: deadlines are checkpoints that extend while the machine is starved. v0.12.0: Native commands now get their piped stdin as raw bytes (no more added \r\n per record, binary input intact) through the new ConvertTo-BashNativeStdin step the transpiler emits ahead of a native command; cat feeds natives the same way. Fix: mv/cp replacing an in-use destination never deletes its own source when the source is named like a leftover (.name.psbash-replaced-*), and a copy that fails part-way restores the original destination instead of losing it. Fix: a pattern with thousands of nested extglob groups ([[ x == @(@(@(...)))]]) is a clean error, not a host-killing stack overflow. Fix: source of a file named Invoke-BashSource.sh works; sourcing an empty file sets $? to 0 as bash does. Older versions: https://github.com/standardbeagle/ps-bash/releases

FileList

Version History

Version Downloads Last updated
0.15.0 (current version) 10 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
Show more