Skip to content

Latest commit

 

History

History
96 lines (93 loc) · 20.1 KB

File metadata and controls

96 lines (93 loc) · 20.1 KB

Command Reference

Part of the Runtime Functions Specification. One row per emulated command: the Invoke-Bash* function, key flags, arg-parsing strategy, and whether it accepts pipeline / file input. Commands implemented as binary cmdlets are documented in detail in Migrated Binary Cmdlets.

Command Function Key Flags Arg Parsing Pipeline File
echo Invoke-BashEcho -n, -e, -E Binary cmdlet (ConvertFromBashArgs; emitter force-quotes -e/-E/-- so they reach Arguments with case intact past the case-insensitive binder) No No
printf Invoke-BashPrintf (format + args) Positional No No
ls Invoke-BashLs -l, -a, -A, -h, -R, -S, -t, -r, -1, -p, -d, -F, --color, -i, -s Binary cmdlet (-a/-A, -d, -p are declared SwitchParameters; rest via ConvertFromBashArgs; bundles recovered post-parse) No Yes
cat Invoke-BashCat -n/--number, -b/--number-nonblank, -s/--squeeze-blank, -E/--show-ends, -T/--show-tabs Binary cmdlet (-E is a declared SwitchParameter; rest via ConvertFromBashArgs; long forms translated to short pre-parse). -A/-e/-t/-v (need -v caret notation) remain unsupported. Yes Yes
grep Invoke-BashGrep -i, -v, -n, -c, -r, -l, -E, -F, -w, -A, -B, -C, -e, -m, -q, -o, -H, -h Binary cmdlet (-i/-v/-c/-w declared as SwitchParameters I/V/C/W; -e declared as value-bearing string[] E; -A/-B declared as nullable int? A/int? B; other flags + bundled forms stay in Arguments). Recursive default-prune: -r skips the FileSystemHelpers.DefaultPrunedDirectories set (.git, .hg, .svn, .vs, node_modules, bin, obj) BEFORE descending, streaming matches as the tree is walked. This is a deliberate divergence from GNU grep -r (which prunes nothing) — it fixes the host idle-timeout the old AllDirectories walk tripped on big repos. Set env PSBASH_SEARCH_NO_IGNORE=1 (truthy) to disable pruning and restore the unfiltered walk. Yes Yes
rg Invoke-BashRg -i, -w, -c, -l, -n, -N, -o, -v, -F, -g, -A, -B, -C, --hidden, --no-ignore/-u/-uu Binary cmdlet (-i/-v/-c/-w declared as SwitchParameters I/V/C/W; -A/-B declared as nullable int? A/int? B; other flags + bundled forms stay in Arguments; native rg.exe passthrough when on PATH, else internal regex engine). Default-prune (internal engine only): prunes the shared DefaultPrunedDirectories set + hidden (unless --hidden) BEFORE descending, streaming results — approximating ripgrep's gitignore filtering. --no-ignore/-u (or -uu to also add hidden) and env PSBASH_SEARCH_NO_IGNORE=1 disable the prune set. The native-rg.exe passthrough does its own .gitignore filtering. Yes Yes
sort Invoke-BashSort -r, -n, -g, -u, -f, -k, -t, -h, -V, -M, -c, -b, -d, -s + long forms --reverse/--numeric-sort/--general-numeric-sort/--unique/--ignore-case/--key=/--field-separator=/--human-numeric-sort/--version-sort/--month-sort/--check/--dictionary-order/--ignore-leading-blanks/--stable/--sort=WORD Binary cmdlet (-c / -d / -V declared as SwitchParameters C / D / V; rest + long forms parsed in Arguments). -g/--general-numeric-sort parses each field as a general float (handles 1e3). Yes Yes
head Invoke-BashHead -n/--lines, -c/--bytes, -q/--quiet/--silent (no-op) Binary cmdlet (manual value-flag scan). -v/--verbose unsupported (no per-file ==> headers emitted). Yes Yes
tail Invoke-BashTail -n/--lines, -c/--bytes, -f/--follow, -s, -q/--quiet/--silent (no-op) Binary cmdlet (manual value-flag scan). -v/--verbose unsupported. Yes Yes
wc Invoke-BashWc -l/--lines, -w/--words, -c/--bytes, -m/--chars, -L/--max-line-length Binary cmdlet (-w is a declared SwitchParameter; rest + long forms via ConvertFromBashArgs) Yes Yes
find Invoke-BashFind -name/-iname, -path/-ipath, -regex/-iregex, -type, -size, -maxdepth/-mindepth, -mtime, -newer, -empty, -print0, -prune, -delete, -depth, -exec; boolean expression operators -a/-and, -o/-or, -not/!, ( ) grouping, -true/-false Binary cmdlet (predicates compiled to leaf delegates, combined by a per-item boolean-expression evaluator with GNU precedence ! > AND > OR; implicit-AND of sequential predicates is byte-identical to the old flat filter). Binder note: the infix -o (vs -OutVariable/-OutBuffer) and -a (vs the cmdlet's own -Arguments) are position-critical, so the emitter force-quotes them (PsEmitter.FindForceQuoteFlags) rather than declaring switch decoys, which would lose position. Bare ! works (the parser keeps a post-command-word ! as a literal operand). Unsupported-predicate classifier: valid-but-unimplemented predicates (-perm, -user, -printf, …) emit find: unsupported predicate and continue; any other dash-led token is rejected with find: unknown predicate '<arg>' (exit 1) rather than being silently swallowed as a search-path operand. No Yes
stat Invoke-BashStat -c, -t, --printf Binary cmdlet (-c FORMAT declared as value-bearing parameter C; -t / --printf= stay in Arguments) No Yes
cp Invoke-BashCp -r/-R, -v, -n, -f, -p, -u, -a Binary cmdlet (manual scan + short-bundle de-bundling; -v/-p declared as decoy switches). -- ends flag parsing. Classifier (exit 2): valid-but-unsupported -i/--interactive, -l/--link, -s/--symbolic-link, -b/--backup, --reflink, -t/--target-directory, etc.; unknown → bash-parity error. No Yes
mv Invoke-BashMv -v, -n, -f Binary cmdlet (manual scan). -- ends flag parsing. Classifier (exit 2): valid-but-unsupported -i/--interactive, -b/--backup, -u/--update, -t/--target-directory, etc.; unknown → bash-parity error. No Yes
rm Invoke-BashRm -r/-R, -f, -v Binary cmdlet (manual scan + bundle). -- ends flag parsing. Classifier (exit 2, fires even under -f): valid-but-unsupported -i/-I/--interactive, -d/--dir, --one-file-system, --*preserve-root; unknown → bash-parity error. Adds path-root + Windows reserved-device-name safety guards. No Yes
mkdir Invoke-BashMkdir -p, -v Binary cmdlet (-p/-v decoy switches; bundles + --parents/--verbose parsed in-loop). -- ends flag parsing. Classifier (exit 2): valid-but-unsupported -m/--mode, -Z/--context; unknown → bash-parity error. Note: bash -pv is the PowerShell -PipelineVariable alias and is eaten by the binder (use -vp or separate -p -v). No Yes
rmdir Invoke-BashRmdir -p, -v Binary cmdlet (-p/-v decoy switches; bundles + --parents/--verbose parsed in-loop). -- ends flag parsing. Classifier (exit 2): valid-but-unsupported --ignore-fail-on-non-empty, -Z/--context; unknown → bash-parity error. No Yes
touch Invoke-BashTouch -d, -a, -m, -c Manual loop No Yes
ln Invoke-BashLn -s, -f, -v Manual loop No Yes
ps Invoke-BashPs -e/-A, -f, -u, -p, --sort, -o Binary cmdlet (-e / -A declared as SwitchParameters E / A; -p / -o declared as nullable strings P / O; -f / -u / --sort / aux stay in Arguments) No No
sed Invoke-BashSed -n, -i, -E, -e Manual loop Yes Yes
awk Invoke-BashAwk -F, -v, -f Binary cmdlet (-v VAR=VAL declared as value-bearing string[] V — bare -v prefix-collides with the -Verbose common parameter; -F/-f and joined forms stay in Arguments). Backed by a real recursive-descent AWK interpreter (AwkInterpreter/AwkLexer/AwkParser/AwkMachine/AwkValue/AwkPrintf), not a flag table — the psm1 regex/string-scan approximation was replaced, closing the five differential gaps (field string-concat, +=, index(), split(), if/else) Yes Yes
cut Invoke-BashCut -d/--delimiter, -f/--fields, -c/--characters, -s/--only-delimited, --output-delimiter Binary cmdlet (-d and -c are declared value-bearing parameters D / C; -f, joined short forms, and the long-form aliases stay in Arguments). -b/--bytes and --complement unsupported. Yes Yes
tr Invoke-BashTr -d, -s Binary cmdlet (-d/-c declared as SwitchParameters; -s/-t and bundled forms stay in Arguments) Yes No
uniq Invoke-BashUniq -c, -d, -u, -i, -f, -s, -w Binary cmdlet (-c/-d/-i declared SwitchParameters; -u/-f/-s/-w and bundled forms stay in Arguments) Yes Yes
rev Invoke-BashRev (none) Positional Yes Yes
nl Invoke-BashNl -ba Manual loop Yes Yes
diff Invoke-BashDiff -u Manual loop No Yes
comm Invoke-BashComm -1, -2, -3, --total Binary cmdlet (digit-bundle scan in Arguments; no colliding flags). --total appends a c1<TAB>c2<TAB>c3<TAB>total summary line. No Yes
column Invoke-BashColumn -t, -s Binary cmdlet (manual scan; no colliding flags) Yes Yes
join Invoke-BashJoin -t, -1, -2 Binary cmdlet (manual value-flag scan) No Yes
paste Invoke-BashPaste -d, -s Manual loop Yes Yes
tee Invoke-BashTee -a/--append Binary cmdlet (-a is a declared SwitchParameter; --append long form + -- end-of-flags handled in the manual scan). Valid-but-unsupported: --ignore-interrupts, --output-error, -p (classifier → exit 2). Yes Yes
xargs Invoke-BashXargs -I, -n, -L, -r, -t, -0, -P Binary cmdlet (-I REPLACE declared as value-bearing parameter I; -P N declared as int? P; -n/-L/-r/-t/-0/-p stay in Arguments) Yes No
jq Invoke-BashJq -r, -c, -S, -s Manual loop Yes Yes
date Invoke-BashDate -d, -u, -r, +FORMAT Binary cmdlet (-d declared as value-bearing parameter D; -u / -r / +FORMAT stay in Arguments) No No
seq Invoke-BashSeq -s, -w Manual loop No No
expr Invoke-BashExpr (expression tokens) Positional No No
du Invoke-BashDu -h, -s, -a, -c, -d/--max-depth, --exclude=GLOB Binary cmdlet (-a / -c declared as SwitchParameters; -d N as nullable int? D; -h / -s and joined -dN stay in Arguments). --exclude=GLOB prunes matching files/dirs (any path segment match prunes the subtree). No Yes
tree Invoke-BashTree -a, -d, -L, -I, --dirsfirst Binary cmdlet (-a / -d declared as SwitchParameters; -I declared as a value-bearing string parameter; -L and --dirsfirst stay in Arguments) No Yes
env Invoke-BashEnv (none) Positional No No
basename Invoke-BashBasename -s Manual loop No No
dirname Invoke-BashDirname (none) Positional No No
pwd Invoke-BashPwd -P Binary cmdlet (-P is a declared SwitchParameter) No No
hostname Invoke-BashHostname (none) None No No
whoami Invoke-BashWhoami (none) None No No
fold Invoke-BashFold -w, -s, -b Binary cmdlet (-w is a declared value-bearing parameter; -s is a declared SwitchParameter; -b and joined -wN/--width=N stay in Arguments) Yes Yes
expand Invoke-BashExpand -t/--tabs, -i/--first-only Manual loop. -i converts only leading (pre-text) tabs. Yes Yes
unexpand Invoke-BashUnexpand -t, -a Manual loop Yes Yes
strings Invoke-BashStrings -n Manual loop Yes Yes
split Invoke-BashSplit -l, -d, -a Manual loop Yes Yes
tac Invoke-BashTac -s Manual loop Yes Yes
base64 Invoke-BashBase64 -d/--decode, -w/--wrap, -i/--ignore-garbage Manual loop (-d/-w/-i declared as decoy params D/W/I for common-param collisions). -i skips non-alphabet chars on decode. Yes Yes
md5sum Invoke-BashMd5sum -c, -b (delegates to Invoke-BashChecksum) Yes Yes
sha1sum Invoke-BashSha1sum -c, -b (delegates to Invoke-BashChecksum) Yes Yes
sha256sum Invoke-BashSha256sum -c, -b (delegates to Invoke-BashChecksum) Yes Yes
file Invoke-BashFile -b, -i, -L Manual loop No Yes
gzip Invoke-BashGzip -d, -c, -k, -f, -v, -l, -t, -r/--recursive, -q/--quiet, -S SUF/--suffix, --fast/--best, -1..-9; accept-and-ignore -n/--no-name, -N/--name, -a/--ascii, --rsyncable, --synchronous, -L/--license Binary cmdlet (-d/-c/-v/-f declared as SwitchParameters D/C/V/F; the rest + bundled forms stay in Arguments). Full flag coverage — every documented GNU gzip flag now maps to real behavior or an explicit accept-and-ignore no-op (the accept-ignore set has no faithful mapping on the .NET GZipStream header surface: no stored name/timestamp/text-mode controls). -r expands a directory operand into its files; -S/--suffix overrides the .gz suffix on both compress and decompress; a directory without -r and a decompress whose name lacks the suffix warn (suppressed by -q). Unknown short flag → invalid option -- 'X' (exit 2); unknown long → unrecognized option (exit 2). Yes Yes
tar Invoke-BashTar -c, -x, -t, -f, -z, -v, -k/--keep-old-files, -a/--auto-compress (gzip-by-extension), --strip-components=N, -O/--to-stdout, --directory=DIR, --exclude=PATTERN; accept-and-ignore --overwrite, -m/--touch, --wildcards/--no-wildcards, -p, --*-owner/--*-permissions Binary cmdlet (-c / -v declared as SwitchParameters C / V; -f FILE declared as nullable string? F; -x / -t / -z / -k and bundled forms stay in Arguments). Within-.NET-limits full coverage: the only refused flags are compression formats with no managed .NET BCL codec — -j/--bzip2, -J/--xz, --lzma/--lzip/--lzop, --zstd, -Z/--compress — which produce a "recognized but not supported" error (exit 2) including in a bundle (-cjf is refused, never silently written uncompressed). gzip (-z) is the only filter System.IO.Compression ships. Known gap: the case-insensitive binder collapses bash -c (create) and -C (change-dir) onto the same C switch — callers must use --directory=DIR for the change-dir flag. No Yes
yq Invoke-BashYq -r, -o Binary cmdlet (-o declared as value-bearing parameter O — prefix-collides with -OutVariable / -OutBuffer; -r and --output-format stay in Arguments; delegates YAML parse + jq filter + output to psm1 helpers via param-bound InvokeScript) Yes Yes
xan Invoke-BashXan -d, subcommands: headers, count, select, search, table Binary cmdlet (-d is a declared value-bearing parameter D; subcommand keyword stays in Arguments) Yes Yes
sleep Invoke-BashSleep (duration) Positional No No
time Invoke-BashTime (command) Positional No No
which Invoke-BashWhich -a Manual loop No No
ping Invoke-BashPing -c/-n count, -W timeout, -t Binary cmdlet (manual scan; managed System.Net.NetworkInformation.Ping). Emits one PsBash.PingReply object per probe — BashText native-style line + Seq/Address/Time/Ttl/Status + latency class (ok/slow/high/timeout). Pipe to Show-Styled (auto net sheet) for the interactive viewer No No
tracert / traceroute Invoke-BashTraceroute -m/-h maxhops, -w/-W timeout Binary cmdlet (manual scan). Prefers the native traceroute/tracert binary (TTL tracing needs raw sockets), wrapping each hop line as a PsBash.TraceHop object (BashText + Hop/Address/Time + latency class); managed Ping TTL fallback when no native binary (needs cap_net_raw). Auto net sheet No No
alias Invoke-BashAlias -p, -u, -a Binary cmdlet (-p / -a declared as SwitchParameters P / A; -u stays in Arguments; psm1-scoped $script:BashUserAliases accessed via parameter-bound InvokeScript) No No
trap Invoke-BashTrap -p, -l Binary cmdlet (-p declared as SwitchParameter P; -l stays in Arguments; psm1-scoped $script:BashTrapHandlers accessed via parameter-bound InvokeScript; ERR/EXIT also publish $global:__BashTrapERR / $global:__BashTrapEXIT scriptblocks) No No
unset Invoke-BashUnset -v, -f Manual loop No No
pushd Invoke-BashPushd +N Binary cmdlet (no declared switches; shares PowerShell's built-in location stack via Push-Location / Pop-Location -Stack) No No
popd Invoke-BashPopd +N Binary cmdlet (no declared switches; shares PowerShell's built-in location stack) No No
dirs Invoke-BashDirs -c, -p, -v Binary cmdlet (-c / -p / -v declared as SwitchParameters C / P / V; shares PowerShell's built-in location stack) No No
yes Invoke-BashYes STRING Positional Yes No
tput Invoke-BashTput CAPNAME Manual loop No No
shopt Invoke-BashShopt -s, -u, -p, -q Manual loop No No
type Invoke-BashType -t, -a, -p Binary cmdlet (-a and -p are declared SwitchParameters A / P; -t stays in Arguments) No No
command Invoke-BashCommand -v, -V, -p Binary cmdlet (-v declared as SwitchParameter V-V collapses onto same switch under case-insensitive binder, matching the oracle which treated them identically; -p declared as SwitchParameter P — accepted but ignored, oracle parity) No No
source Invoke-BashSource (none) Positional No Yes
shift Invoke-BashShift N Manual loop No No
realpath Invoke-BashRealpath (none) Positional No No
id Invoke-BashId -u, -g, -G, -n, -r Binary cmdlet (no declared switches; manual case-sensitive scan distinguishes -g vs -G; Windows uses WindowsIdentity, Unix shells out to /usr/bin/id) No No
mapfile / readarray Invoke-BashMapfile -n, -O, -s, -t, -d Binary cmdlet (-O declared as int? O, -d declared as string? D; -n / -s / -t stay in Arguments) Yes No
less Invoke-BashLess -N, -i, -S Binary cmdlet (-i declared as SwitchParameter I; -N / -S declared as SwitchParameters for clean binder routing; rest stay in Arguments. Non-interactive: pass-through; interactive: shells out to native less via Process with operands bound through ProcessStartInfo.ArgumentList) Yes Yes
more Invoke-BashMore -N, +NUM Binary cmdlet (-N declared as SwitchParameter N; +NUM positional stays in Arguments. Non-interactive: emits all input lines as PsBash.TextOutput; the oracle's interactive paging loop is not exercised in SDK runspaces) Yes Yes
test / [ Invoke-BashTest -e -f -d -r -w -x -s -L -h -z -n, = != -eq -ne -lt -le -gt -ge, ! -a -o Binary cmdlet (colliding bare flags -e / -d / -w / -a / -o declared as SwitchParameters E / D / W / A / O and re-injected into the operand list post-parse; rest stay in Arguments) No No
read Invoke-BashRead -r, -p, -a, -n, -N, -t, -s Binary cmdlet (-p declared as string? P, -a declared as string? A; -r/-n/-N/-t/-s stay in Arguments) Yes No
browse Invoke-BashBrowse --list, -PassThru, -Inspect, -Select, -Action, -Exec, -Force Binary cmdlet (all long-name flags; no colliding short flags. Non-interactive list path renders typed PsBash.BrowseRow PSObjects via psm1 ConvertTo-BrowseRow; interactive TTY path hands off to psm1 Invoke-BrowseInteractive; optional Out-GridView enhancement when present and stdin is a real terminal) Yes No

Additional aliases: printenv -> Invoke-BashEnv, gunzip -> Invoke-BashGzip, zcat -> Invoke-BashGzip, . -> Invoke-BashSource.