buninu 0.4.18 → 0.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/apps/bunmsh/CHANGELOG.md +131 -0
  3. package/apps/bunmsh/PORTING.md +133 -15
  4. package/apps/bunmsh/help/awk.md +38 -0
  5. package/apps/bunmsh/help/break.md +21 -0
  6. package/apps/bunmsh/help/chmod.md +8 -2
  7. package/apps/bunmsh/help/cmp.md +29 -0
  8. package/apps/bunmsh/help/continue.md +22 -0
  9. package/apps/bunmsh/help/cp.md +4 -0
  10. package/apps/bunmsh/help/diff.md +30 -0
  11. package/apps/bunmsh/help/egrep.md +26 -0
  12. package/apps/bunmsh/help/export.md +2 -2
  13. package/apps/bunmsh/help/expr.md +30 -0
  14. package/apps/bunmsh/help/fgrep.md +25 -0
  15. package/apps/bunmsh/help/grep.md +4 -0
  16. package/apps/bunmsh/help/ls.md +4 -2
  17. package/apps/bunmsh/help/mkdir.md +1 -1
  18. package/apps/bunmsh/help/print.md +3 -0
  19. package/apps/bunmsh/help/return.md +23 -0
  20. package/apps/bunmsh/help/sed.md +8 -3
  21. package/apps/bunmsh/help/set.md +12 -3
  22. package/apps/bunmsh/help/tr.md +4 -0
  23. package/apps/bunmsh/help/trap.md +22 -0
  24. package/apps/bunmsh/help/uniq.md +27 -0
  25. package/apps/bunmsh/package.json +1 -1
  26. package/apps/bunmsh/src/awk.js +203 -0
  27. package/apps/bunmsh/src/diff.js +222 -0
  28. package/apps/bunmsh/src/fancy-ls.js +15 -4
  29. package/apps/bunmsh/src/main.js +28 -10
  30. package/apps/bunmsh/src/sed.js +159 -0
  31. package/apps/bunmsh/src/shell.js +1714 -462
  32. package/apps/bunmsh/test/awk-reference.test.js +35 -0
  33. package/apps/bunmsh/test/awk.test.js +62 -0
  34. package/apps/bunmsh/test/posix-bootstrap.test.js +595 -0
  35. package/apps/bunmsh/test/shell1.test.js +64 -0
  36. package/apps/bunmsh/test/utility-reference-cases.mjs +98 -0
  37. package/apps/bunmsh/test/utility-reference.test.js +23 -0
  38. package/apps/jsgotty/client-kitty.mjs +61 -0
  39. package/apps/jsgotty/client.mjs +16 -0
  40. package/apps/jsgotty/package-lock.json +2 -2
  41. package/apps/jsgotty/package.json +1 -1
  42. package/apps/jsgotty/tests/client-kitty.test.mjs +43 -0
  43. package/package.json +1 -1
  44. package/apps/bunmsh/test/shell.test.js +0 -2092
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.20 - 2026-10-13
4
+
5
+ - Sync bunmsh to 0.4.0:
6
+ * Add a pure JavaScript awk fallback, file diff with line alignment, cmp,
7
+ uniq, expr, and egrep/fgrep aliases; extend sed and other utility builtins
8
+ for configure scripts and compiler builds.
9
+ * Improve compound commands, here-documents, parameter expansion, function
10
+ and loop control, descriptor redirection, and pipeline/subshell state
11
+ transfer for Autoconf and GCC bootstrap workloads.
12
+ * In `set -o posix` mode, use plain ls output and pass only exported variables
13
+ and command-prefix assignments to external programs. Default mode retains
14
+ ls icons and its existing environment behavior.
15
+ * Preserve the existing background-process behavior and stable
16
+ `Bun.sha.procs` indices. POSIX and awk compatibility remain partial; see
17
+ the bundled bunmsh PORTING.md for limitations.
18
+ - Sync jsgotty to 1.1.15: forward Kitty graphics to the terminal in `--client`
19
+ mode and avoid applying the corresponding cursor movement twice.
20
+
21
+ ## 0.4.19 - 2026-10-12
22
+
23
+ - Sync bunmsh to 0.3.11: more POSIX syntax
24
+
3
25
  ## 0.4.18 - 2026-09-29
4
26
 
5
27
  - Sync jsgotty to 1.1.14: Kitty for Windows
@@ -2,6 +2,137 @@
2
2
 
3
3
  All notable user-visible changes to bunmsh are documented here.
4
4
 
5
+ ## [0.4.0] - 2026-10-13
6
+
7
+ ### Added and fixed
8
+
9
+ - Respect builtin cat output redirects in shell subprocesses, including AWK pipes.
10
+
11
+ - Stream external stdout/stderr to the correct pipeline endpoint for `2>&1`,
12
+ `2>&1 >file` and `1>&2`, retaining downstream early-close handling.
13
+
14
+ - Support `cp -p` for regular files, preserving ownership, mode and timestamps.
15
+
16
+ - Evaluate `!` inside if/elif conditions with normal pipeline precedence,
17
+ including conditions joined with `&&` or `||`.
18
+
19
+ - AWK supports parenthesized print lists, continued arguments and buffered
20
+ output command pipes through bunmsh. Correct function parameter scope and
21
+ preserve replacement backslashes; GCC option generators match mawk output.
22
+
23
+ - Process mkdir operands in order so parent/child paths do not race.
24
+
25
+ - Preserve here-document bodies when connecting commands to compound operands.
26
+
27
+ - Distinguish backquoted brace groups from parameter expansions during tokenization.
28
+
29
+ - Handle traditional set - as an option delimiter, preserving bare-call arguments.
30
+
31
+ - Add byte-preserving adjacent-line uniq with -c/-d/-u and input/output files.
32
+ - Ignore empty nonexistent filenames with rm -f, including libtool cleanup.
33
+
34
+ - Recognize case/esac next to subshell parentheses, including nested groups.
35
+
36
+ - Keep awk quoted operator strings as data, including install path concatenation.
37
+
38
+ - Remove the backquote escape layer before parsing command substitutions.
39
+
40
+ - Preserve short circuiting across comments before compounds and parse simple
41
+ pipeline stages before a trailing compound command.
42
+
43
+ - Keep persistent read descriptors open and consume one line without read-ahead.
44
+ - Expand positional parameter lengths such as libtool's ${#1}.
45
+
46
+ - Support explicit-class chmod rwxX modes such as a-w and u+rw.
47
+
48
+ - Recognize comments after else and loop-closing done as compound syntax.
49
+
50
+ - Apply enclosing descriptor redirects to compound-producer pipeline output.
51
+
52
+ - Add bytewise cmp, legacy egrep/fgrep names, and tr squeeze/delete combinations.
53
+ - Adapt mv/rm -- for Bun Shell while protecting option-looking filenames.
54
+
55
+ - Preserve multiline parameter expansion operands inside compound bodies.
56
+ - Accept combined print flags such as Autoconf's -rn.
57
+ - Preserve compound commands and function declarations after recipe continuations.
58
+
59
+ - Match quoted literals and bracket patterns in parameter prefix/suffix removal.
60
+ - Capture subshell state at execution time and scope its internal transport to
61
+ that command, preserving changes from earlier commands in the same list.
62
+ - Treat interior ^ and $ as literals in basic regular expressions, including
63
+ GNU make build.sh object-extension substitutions.
64
+
65
+ - Add a pure JavaScript awk fallback interpreter with fields, arrays, rules,
66
+ functions, loops, string/regex operations and file I/O. Input command pipes
67
+ and system() remain unsupported; full POSIX/GNU compatibility is not claimed.
68
+ - Preserve multiline quoted operands after compound pipeline connectors, quoted
69
+ backslash-newlines, heredoc AND/OR continuations, and case terminators after groups.
70
+ - Preserve ASCII control characters used as Autoconf awk separators during expansion.
71
+ - Keep nested redirected compound operands when reconstructing pipelines.
72
+ - Support sed r FILE, including end-of-cycle output and silently missing files.
73
+
74
+ - Add offline system diff/sed reference fixtures so isolated tests can compare
75
+ output and exit status without depending on host executables in the guest.
76
+
77
+ - Add file diff using the jsmdcui Myers line alignment, with separate insertion,
78
+ deletion and replacement hunks, binary notices and missing-final-newline markers.
79
+ - Expand parameters and substitutions inside arithmetic, including Autoconf `$(( $* ))`.
80
+
81
+ - In `set -o posix` mode, send only exported variables and command-prefix
82
+ assignments to external programs, while preserving complete internal state
83
+ for pipeline/subshell Bun children. Default mode still passes all variables.
84
+ - Match newlines with case wildcards, including Autoconf POSIX-mode detection.
85
+ - Keep heredoc contents out of subshell rewriting, support pipelines feeding
86
+ compound cases, accept operand-free rm -f, grep -e/-c, and sed -f.
87
+
88
+ - Track command source lines, preserve quotes and argument boundaries in selected
89
+ parameter operands, and parse nested compound conditions and subshell cases.
90
+ - Add expr and extend fallback sed with addresses, branches and hold-space edits.
91
+ - Make `set -o posix` an observable option: only this mode removes fallback ls
92
+ icons and implicit directory suffixes. Normal ls and lsfancy retain icons.
93
+ - Support ls inode/dereference options and sorting multiple file operands.
94
+ - Transport large internal subprocess state through a private temporary file;
95
+ retain the full function AST and clean up after foreground execution.
96
+
97
+ - Accept inline and next-line function braces, brace groups with redirects and
98
+ pipelines, multiline pipelines, and nested case clauses with here-documents.
99
+ - Implement return and counted break/continue with function/source/loop boundaries.
100
+ - Add persistent numeric fd bindings for exec, ordered duplication, scoped
101
+ restoration, and descriptor inheritance for external and subshell commands.
102
+ - Add conditional errexit, nounset/noglob, xtrace, option queries, EXIT handlers
103
+ and deferred signal traps. See PORTING.md for the remaining POSIX boundaries.
104
+ - Preserve the minimal background-command contract: original Bun.Subprocess
105
+ objects, append-only stable Bun.sha.procs indices, immediate return and unref;
106
+ no implicit waiting, killing or widening of accepted background syntax.
107
+
108
+ ## [0.3.11] - 2026-10-12
109
+
110
+ ### Fixed
111
+
112
+ - Keep multiline quoted words, command substitutions and here-documents
113
+ together when parsing compound-command bodies, rather than treating their
114
+ continuation lines as separate commands or compound keywords.
115
+
116
+ - Accept additional `if`/`elif` and `while`/`until` header layouts, including
117
+ `then` or `do` on the following line, and execute commands placed on the
118
+ same line after `then`.
119
+
120
+ - Improve comment handling in compound keyword and case-arm scanning, and
121
+ include nearby source text in several compound-syntax error messages.
122
+
123
+ ### Added
124
+
125
+ - Initial support for parenthesized subshell groups, executed in a child
126
+ bunmsh with inherited shell state, including groups embedded in command
127
+ sequences and leading groups followed by `&&`, `||` or `;`.
128
+ Subshell redirection is still limited: the leading-group path handles
129
+ discarding stdout/stderr to `/dev/null`, but does not yet implement
130
+ general file redirection or descriptor duplication.
131
+
132
+ - Recognize general numeric output-descriptor duplication syntax such as
133
+ `3>&1`. Only the existing `1>&2` and `2>&1` handling is implemented for
134
+ ordinary commands; other numeric pairs are currently accepted but ignored.
135
+
5
136
  ## [0.3.10] - 2026-09-29
6
137
 
7
138
  ### Fixed
@@ -38,8 +38,28 @@ pseudo-terminal tests.
38
38
  Background pipelines, builtins, functions, and all redirections are rejected
39
39
  before files are opened. General asynchronous command lists, job control,
40
40
  and coprocesses are not implemented.
41
- - Brace command groups, `select`, arithmetic commands, and `[[ ... ]]` are
42
- not implemented.
41
+ Compatibility invariant: keep the original `Bun.Subprocess` objects in an
42
+ append-only `Bun.sha.procs` array with stable indices, immediate return and
43
+ `unref()`. POSIX foreground work must not add implicit waiting, killing,
44
+ removal of completed entries, or a job-wrapper replacement.
45
+ - Brace command groups run in the current shell, including scoped redirects
46
+ and group pipelines. `select`, arithmetic commands, and `[[ ... ]]` remain
47
+ unimplemented. Function opening braces may be on the same or next line;
48
+ inline bodies and nested case clauses are supported.
49
+ - `return` stops at the function/source boundary; `break N` and `continue N`
50
+ unwind enclosing loops. Functions and sourced files establish their own
51
+ loop boundary, following mksh STOP_BRKCONT.
52
+ - `set -e` uses a dynamically inherited error-ignore context for conditions,
53
+ non-final AND/OR commands and negation, following mksh XERROK. `set -u`,
54
+ `set -f`, `set -x`, option queries and corresponding CLI flags are supported.
55
+ `-v` currently prints initial CLI input only; it is not an incremental reader.
56
+ `set -o posix` is listed and stored as an option. It makes fallback `ls`
57
+ omit icons and automatic directory suffixes; `lsfancy` remains decorative.
58
+ External environments in this mode contain only inherited/exported names
59
+ and command-prefix assignments. Full variables and export attributes travel
60
+ with internal pipeline/subshell state, separately from the native environment.
61
+ Default mode continues passing all shell variables to external programs.
62
+ It does not imply full POSIX conformance.
43
63
  - Functions and subshells cover practical cases but do not yet reproduce every
44
64
  mksh scoping, local-variable, trap, and diagnostic edge case.
45
65
  - Pipelines isolate builtin/function state through subprocess copies. Changes
@@ -75,9 +95,17 @@ pseudo-terminal tests.
75
95
  pathname expansion, or tilde expansion, and a trailing newline is appended.
76
96
  It follows the same dash/`/bin/sh` comparison harness as everything else in
77
97
  this codebase, except `<<<` itself, since dash does not implement it.
78
- - Arbitrary descriptor allocation/manipulation, descriptor variables,
79
- heredocs targeting a descriptor other than stdin, and every ordering edge
80
- case remain incomplete.
98
+ - Numeric file descriptors support file open, append, read/write (`<>`),
99
+ duplication and shell-level closure, with left-to-right redirect ordering.
100
+ `exec` without a command persists bindings. Compound/function redirections
101
+ restore only the descriptors they changed; native open handles retained by
102
+ another binding stay alive. External/pipeline children inherit extra fds
103
+ through Bun.spawn stdio. No native compiler or host shell is required.
104
+ - Descriptor variables and heredocs targeting non-stdin fds are not implemented.
105
+ Closing a descriptor denies subsequent shell duplication/use, but Bun.spawn
106
+ maps a closed child stdio slot to `ignore` (/dev/null), not native EBADF.
107
+ Aliases of captured stdout/stderr passed as extra fds to an arbitrary external
108
+ program do not yet reproduce every pipe/capture ordering case.
81
109
  - External processes use `Bun.spawn`; regular and fallback builtins may execute
82
110
  in-process or in a self-spawned bunmsh pipeline child depending on streaming
83
111
  and state-isolation requirements.
@@ -96,13 +124,16 @@ pseudo-terminal tests.
96
124
  - Ctrl-D on an empty readline input sends EOF and exits the interactive shell.
97
125
  This is deliberately distinct from Ctrl-C, following the same high-level
98
126
  editor/main-loop separation used by mksh.
99
- - The current implementation handles SIGINT through readline while editing and
100
- through a process signal listener while a foreground operation owns the
101
- terminal. It does not yet have mksh's general pending-signal table and safe
102
- trap checkpoints.
103
- - There is no `trap` builtin or support for user handlers for signals, `EXIT`,
104
- or `ERR`. Signal handlers therefore cannot yet execute shell source, be
105
- listed, ignored, reset, or inherited with POSIX/mksh semantics.
127
+ - `trap` supports listing, reset (`-`), shell-local ignore (empty action),
128
+ EXIT/0 and catchable signal names/numbers. Signal callbacks enqueue handlers;
129
+ shell source runs at command boundaries, following mksh's pending-trap model.
130
+ Handlers preserve `$?`; EXIT runs once and can explicitly override status.
131
+ Shell finalization releases its fd resources and listeners, never background
132
+ subprocesses or Bun.sha.procs entries.
133
+ - Complete native signal semantics are not claimed: ignored handlers do not
134
+ establish inherited SIG_IGN in external children, handlers waiting at an idle
135
+ interactive prompt run at the next command boundary, and there is no ERR trap,
136
+ process-group forwarding, `wait` integration or general builtin cancellation.
106
137
  - Status 130 is defined for an interrupted `serve`, and its SIGTERM path uses
107
138
  143. Signal-derived statuses are not yet normalised consistently for every
108
139
  external command, builtin, pipeline stage, and command substitution.
@@ -182,11 +213,11 @@ pseudo-terminal tests.
182
213
 
183
214
  ## Remaining major work
184
215
 
185
- 1. Background jobs, process groups, complete signal-status handling, traps,
216
+ 1. General background jobs, process groups, complete signal/trap inheritance,
186
217
  general builtin cancellation, and `jobs`/`fg`/`bg`/`wait`.
187
- 2. Shell options such as `errexit`, `nounset`, `pipefail`, `xtrace`, and POSIX
218
+ 2. Full shell-option edge cases, `pipefail`, incremental verbose input and POSIX
188
219
  mode, plus startup/login/restricted-shell files and modes.
189
- 3. Brace groups, `[[ ... ]]`, arithmetic commands,
220
+ 3. `[[ ... ]]`, arithmetic commands,
190
221
  extended globs, process substitution, and fuller mksh expansion semantics.
191
222
  4. Arrays, associative arrays, namerefs, `typeset`/scope semantics, and more
192
223
  complete special builtins.
@@ -194,3 +225,90 @@ pseudo-terminal tests.
194
225
  `fc`, and automatic history policy.
195
226
  6. Broader POSIX conformance testing, mksh `check.t` coverage, exact diagnostics,
196
227
  and exit-status compatibility for edge cases.
228
+
229
+ ## Bootstrap compatibility verification (2026-10-13)
230
+
231
+ Implementation reference: sibling `mksh/syn.c` (`function_body`/brace grammar),
232
+ `exec.c` (TBRACE, XERROK, E_LOOP), `funcs.c` (c_exitreturn, c_brkcont, c_trap),
233
+ and `histrap.c` (runtrap/cleartraps). The JavaScript execution and descriptor
234
+ model is adapted to Bun; no C code or native signal/job-control layer is copied.
235
+
236
+ `test/posix-bootstrap.test.js` covers finite control-flow, descriptor, trap,
237
+ option and background-registry cases without requiring a reference shell.
238
+ Tests were run with musl Bun 1.4.2 in `bunproot -r rfs1`. The guest's `/bin/sh`
239
+ is itself bunmsh, so reference.test.js comparisons there would not constitute
240
+ an independent POSIX oracle.
241
+
242
+ The next configure compatibility batch adds physical source-line tracking for
243
+ ordinary commands and nested function/case bodies, quoted parameter operands
244
+ (including `${1+"$@"}`), compound conditions containing nested groups/if, and
245
+ multiline subshells containing case clauses. LINENO handling is not yet complete
246
+ for every condition, eval, subshell, or user-assignment edge case.
247
+
248
+ The sed fallback now has addresses/ranges, labels/branches, pattern/hold-space
249
+ operations, and text commands; expr provides arithmetic/comparison/BRE matching.
250
+ File diff uses the jsmdcui Myers alignment and normal-format change hunks;
251
+ directory comparison and unified/context output are not implemented.
252
+ Subprocess state still includes the complete function AST. Large internal state
253
+ uses a private temporary file cleaned by the spawning foreground process. This
254
+ avoids the observed bunproot environment-string limit without changing the
255
+ Bun.sha.procs registry or background process lifecycle.
256
+
257
+ GNU make 4.4.1 configure validation is ongoing; no complete run is claimed.
258
+ Its LINENO/re-exec blockers and large unexported test-source environment values
259
+ have dedicated regressions. Autoconf's multiline case wildcard now detects the
260
+ listed posix option and enables it. Further utility/parser blockers may remain.
261
+
262
+ Independent utility references can be recorded outside the bootstrap guest with
263
+ `node test/utility-reference-cases.mjs OUTPUT.json`, using `/usr/bin/diff` and
264
+ `/usr/bin/sed`. Make only that JSON data accessible inside the guest, then run
265
+ `BUNMSH_UTILITY_REFERENCE=/guest/OUTPUT.json bun test test/utility-reference.test.js`.
266
+ The test compares status, stdout and stderr from explicit bunmsh builtins; it
267
+ does not invoke or mount host reference executables. Without the environment
268
+ variable, the reference fixture suite is skipped explicitly.
269
+
270
+ The current 13 file-diff and 15 sed cases passed under musl Bun/bunproot against
271
+ GNU diffutils 3.10 and GNU sed 4.9. They cover middle edits, repeated lines,
272
+ newline boundaries, UTF-8, sed script files, addresses, branches, hold space and file reads.
273
+ These are selected compatibility cases, not a claim of complete GNU behavior.
274
+
275
+ The awk fallback is a JavaScript parser/interpreter in src/awk.js, with no
276
+ native awk or FFI dependency. It supports BEGIN/END, pattern/action records,
277
+ fields, associative arrays, functions/control flow, regex/string operations,
278
+ getline and file redirection. Output command pipes run through bunmsh, with
279
+ input buffered until close or program end; streaming and interactive pipe
280
+ communication are not supported. Input command pipes and system() fail
281
+ explicitly. JavaScript regex, string and numeric behavior imposes remaining
282
+ locale/formatting limits; this is not full POSIX or GNU awk compatibility.
283
+ The optional test/awk-reference.test.js suite compares a separately supplied
284
+ BUNMSH_AWK_REFERENCE executable; it is never used by the builtin itself.
285
+
286
+ ### Additional Autoconf regressions
287
+
288
+ Compound normalization removes only lexer-recognized line continuations; it
289
+ preserves backslash-newlines inside single quotes and heredoc bodies. Case `;;`
290
+ terminators remain adjacent after brace groups. AND/OR operators continue across
291
+ heredoc bodies, and pipelines retain redirected compound operands. Expansion
292
+ markers use reserved Unicode noncharacters instead of ASCII control bytes, so
293
+ Autoconf's BEL separator reaches awk intact. Sed `r FILE` appends raw file data
294
+ at the end of the cycle (including after `d`); missing files contribute nothing.
295
+
296
+ GNU make build.sh additionally exercises bracket/quoted parameter trimming and
297
+ subshell snapshots taken at execution time. Internal state transport is scoped
298
+ to its command even outside POSIX mode; default user variable export behavior
299
+ and the background process registry are unchanged. Basic regex anchors are
300
+ context-sensitive so literal make variable references can be substituted.
301
+
302
+ Binutils bootstrap coverage additionally includes multiline `${...}` operands
303
+ inside compound bodies, legacy egrep/fgrep fallback names, bytewise cmp (normal
304
+ and quiet modes), tr squeezing with optional translation/deletion, and an
305
+ adapter for Bun Shell mv's missing `--` support. The adapter protects filenames
306
+ beginning with `-` by prefixing `./` after removing the option delimiter. The
307
+ cmp and tr subset has offline GNU command reference fixtures;
308
+ unsupported extensions remain errors, not successful no-ops.
309
+
310
+ The uniq fallback preserves byte comparisons and adjacent groups, supports
311
+ -c/-d/-u, -- and input/output operands. Other GNU extensions are explicit
312
+ errors. Twelve GNU reference fixtures cover ordering, flags, blank lines,
313
+ missing final newlines and NUL bytes. rm -f discards empty nonexistent path
314
+ operands before Bun Shell can incorrectly treat them as the current directory.
@@ -0,0 +1,38 @@
1
+ ## awk
2
+
3
+ Scan records and evaluate AWK programs using a JavaScript interpreter.
4
+
5
+ ### Usage
6
+
7
+ ```sh
8
+ awk [-F SEPARATOR] [-v NAME=VALUE] [-f SCRIPT_FILE] [PROGRAM] [FILE ...]
9
+ ```
10
+
11
+ ### Options and forms
12
+
13
+ - `-F`: Set the field separator; `-v`: assign a variable before BEGIN.
14
+ - `-f`: Read program text from a file; `-e`: append program text.
15
+ - BEGIN/END, pattern/action rules, fields, variables, associative arrays,
16
+ functions, conditionals, loops, next/nextfile, exit and delete.
17
+ - print/printf, arithmetic, comparisons, regular expressions, concatenation,
18
+ split, substr, index, length, match, sub/gsub and common numeric functions.
19
+ - getline from input or files; file output with `>` and `>>`; close.
20
+ - Parenthesized print/printf lists and continued arguments after commas.
21
+ - Output pipes run through bunmsh, buffering input until close or program end.
22
+ They do not provide streaming or interactive communication. close returns
23
+ the command status; closing and reopening starts a fresh command.
24
+ - This is a subset, not full POSIX/GNU compatibility. Input command pipes and
25
+ system() are unsupported and report errors. Text processing uses JavaScript strings
26
+ and regular expressions; locale and floating-point edge cases may differ.
27
+
28
+ ### Example
29
+
30
+ ```sh
31
+ printf 'apple 2\npear 3\n' | awk '{total += $2} END {print total}'
32
+ ```
33
+
34
+ Output:
35
+
36
+ ```text
37
+ 5
38
+ ```
@@ -0,0 +1,21 @@
1
+ ## break
2
+
3
+ Leave N enclosing loops (default 1). N must be positive. Function calls establish their own loop boundary.
4
+
5
+ ### Usage
6
+
7
+ ```sh
8
+ break [N]
9
+ ```
10
+
11
+ ### Example
12
+
13
+ ```sh
14
+ for x in a b; do echo "$x"; break; done
15
+ ```
16
+
17
+ Output:
18
+
19
+ ```text
20
+ a
21
+ ```
@@ -1,6 +1,6 @@
1
1
  ## chmod
2
2
 
3
- Change modes using octal values, +x, or a+x.
3
+ Change file modes using octal values or symbolic permission changes.
4
4
 
5
5
  ### Usage
6
6
 
@@ -11,7 +11,13 @@ chmod MODE FILE ...
11
11
  ### Options and forms
12
12
 
13
13
  - Octal modes such as `755` set all permission bits.
14
- - `+x` and `a+x` add executable bits.
14
+ - `+x` retains its existing shorthand for adding executable bits for everyone.
15
+ - Explicit classes `u`, `g`, `o`, or `a` support `+`, `-`, and `=` with `rwxX`.
16
+ - `X` adds execution only for directories or files already executable.
17
+ - Comma-separated clauses and multiple operations are applied in order.
18
+ - Examples: `a-w`, `u+rw`, `go=rx`, `u=rw,g=r,o=`.
19
+ - Recursive mode, permission copying, `s`/`t`, and omitted classes other than
20
+ the existing `+x` shorthand are not implemented.
15
21
 
16
22
  ### Example
17
23
 
@@ -0,0 +1,29 @@
1
+ ## cmp
2
+
3
+ Compare two files byte by byte. Return 0 for identical data, 1 for differences,
4
+ and 2 for errors. `-` reads standard input.
5
+
6
+ ### Usage
7
+
8
+ ```sh
9
+ cmp [-s] [--] FILE1 FILE2
10
+ ```
11
+
12
+ `-s` (also `--silent` or `--quiet`) suppresses difference and file-error messages.
13
+ Without it, report the first differing byte and line, or which file ends first.
14
+ Byte offsets, `-l`, and other GNU extensions are not implemented.
15
+
16
+ ### Example
17
+
18
+ ```sh
19
+ printf same > first
20
+ printf same > second
21
+ cmp -s first second
22
+ echo $?
23
+ ```
24
+
25
+ Output:
26
+
27
+ ```text
28
+ 0
29
+ ```
@@ -0,0 +1,22 @@
1
+ ## continue
2
+
3
+ Continue the Nth enclosing loop (default 1). N must be positive.
4
+
5
+ ### Usage
6
+
7
+ ```sh
8
+ continue [N]
9
+ ```
10
+
11
+ ### Example
12
+
13
+ ```sh
14
+ for x in a b; do echo "$x"; continue; echo skipped; done
15
+ ```
16
+
17
+ Output:
18
+
19
+ ```text
20
+ a
21
+ b
22
+ ```
@@ -6,12 +6,16 @@ Copy files and directories.
6
6
 
7
7
  ```sh
8
8
  cp [-rRv] SOURCE ... DESTINATION
9
+ cp -p [-v] [--] FILE ... DESTINATION
9
10
  ```
10
11
 
11
12
  ### Options and forms
12
13
 
13
14
  - `-r`, `-R`: Copy directories recursively (`-r` is translated to Bun Shell's `-R`).
14
15
  - `-v`: Request verbose output.
16
+ - `-p`: Preserve regular-file ownership, permissions and access/modification
17
+ times. Multiple sources require a directory destination; recursive `-p`
18
+ combinations are not yet supported and report an error.
15
19
  - `-n`: Accepted by Bun Shell but currently does not prevent overwriting.
16
20
 
17
21
  ### Example
@@ -0,0 +1,30 @@
1
+ ## diff
2
+
3
+ Compare two files. Return 0 when identical, 1 when different, or 2 on error.
4
+
5
+ ### Usage
6
+
7
+ ```sh
8
+ diff [-q] [--] FILE1 FILE2
9
+ ```
10
+
11
+ Print normal-format changes, or use `-q`/`--brief` for a difference notice.
12
+ Binary differences produce a notice. Text differences use Myers line alignment, preserving unchanged lines
13
+ between separate additions, deletions, and replacements. Missing final
14
+ newlines are reported explicitly. Directory comparison and unified/context formats are not supported.
15
+ The default shell alias's `--color` option is accepted; output is plain text.
16
+
17
+ ### Example
18
+
19
+ ```sh
20
+ printf 'first\nlast\n' > before
21
+ printf 'first\nnew\nlast\n' > after
22
+ diff before after
23
+ ```
24
+
25
+ Output:
26
+
27
+ ```text
28
+ 1a2
29
+ > new
30
+ ```
@@ -0,0 +1,26 @@
1
+ ## egrep
2
+
3
+ Search using extended regular expressions, equivalent to `grep -E`.
4
+
5
+ ### Usage
6
+
7
+ ```sh
8
+ egrep [OPTIONS] PATTERN [FILE ...]
9
+ ```
10
+
11
+ ### Options and forms
12
+
13
+ Accepts the same supported options as builtin `grep`.
14
+
15
+ ### Example
16
+
17
+ ```sh
18
+ printf 'red\nblue\ngreen\n' | builtin egrep 'red|blue'
19
+ ```
20
+
21
+ Output:
22
+
23
+ ```text
24
+ red
25
+ blue
26
+ ```
@@ -1,11 +1,11 @@
1
1
  ## export
2
2
 
3
- Set or list environment variables.
3
+ Mark variables for export, or list them. In `set -o posix` mode, external programs receive only inherited/exported variables and command-prefix assignments. Shell pipelines and subshells retain all shell variables through internal state transfer. Outside POSIX mode, bunmsh preserves its default of passing all variables to external programs.
4
4
 
5
5
  ### Usage
6
6
 
7
7
  ```sh
8
- export [NAME[=VALUE] ...]
8
+ export [-p] [NAME[=VALUE] ...]
9
9
  ```
10
10
 
11
11
  ### Example
@@ -0,0 +1,30 @@
1
+ ## expr
2
+
3
+ Evaluate integer, string, and basic regular-expression expressions.
4
+
5
+ ### Usage
6
+
7
+ ```sh
8
+ expr [--] EXPRESSION
9
+ ```
10
+
11
+ ### Options and forms
12
+
13
+ - Arithmetic: `+`, `-`, `*`, `/`, `%`, with parentheses and precedence.
14
+ - Comparisons: `=`, `!=`, `<`, `<=`, `>`, `>=`.
15
+ - `|` selects the first nonempty, nonzero operand; `&` requires both operands.
16
+ - `STRING : BRE` returns the first capture, or the matched prefix length when there is no capture.
17
+ - Status is 0 for a nonempty, nonzero result, 1 for empty or zero, and 2 for an error.
18
+ - Quote operators that the shell would otherwise interpret.
19
+
20
+ ### Example
21
+
22
+ ```sh
23
+ expr 2 + 3 '*' 4
24
+ ```
25
+
26
+ Output:
27
+
28
+ ```text
29
+ 14
30
+ ```
@@ -0,0 +1,25 @@
1
+ ## fgrep
2
+
3
+ Search for fixed strings, equivalent to `grep -F`.
4
+
5
+ ### Usage
6
+
7
+ ```sh
8
+ fgrep [OPTIONS] PATTERN [FILE ...]
9
+ ```
10
+
11
+ ### Options and forms
12
+
13
+ Accepts the same supported options as builtin `grep`.
14
+
15
+ ### Example
16
+
17
+ ```sh
18
+ printf 'a.b\naxb\n' | builtin fgrep 'a.b'
19
+ ```
20
+
21
+ Output:
22
+
23
+ ```text
24
+ a.b
25
+ ```
@@ -32,3 +32,7 @@ Output:
32
32
  ```text
33
33
  beta
34
34
  ```
35
+
36
+ Repeated `-e PATTERN` options combine patterns with OR. `-c` prints the number of selected lines per input file.
37
+
38
+ The fallback names `egrep` and `fgrep` select `grep -E` and `grep -F`.
@@ -1,11 +1,11 @@
1
1
  ## ls
2
2
 
3
- Use the lsfancy emoji and terminal-width-aware listing.
3
+ Use the lsfancy emoji and terminal-width-aware listing. With `set -o posix`, fallback `ls` omits icons and automatic directory suffixes. Explicit `-F` suffixes still apply; `lsfancy` always retains its icons.
4
4
 
5
5
  ### Usage
6
6
 
7
7
  ```sh
8
- ls [-aAdlhRtrS1F] [PATH ...]
8
+ ls [-aAdilhLRtrS1F] [PATH ...]
9
9
  ```
10
10
 
11
11
  Because `-h` means human-readable sizes, use `--help` to display this page.
@@ -16,6 +16,8 @@ Because `-h` means human-readable sizes, use `--help` to display this page.
16
16
  - `-A`: Include hidden entries except `.` and `..`.
17
17
  - `-d`: List directories themselves rather than their contents.
18
18
  - `-l`: Use long format.
19
+ - `-i`: Print inode numbers.
20
+ - `-L`: Follow symbolic links.
19
21
  - `-h`: Show human-readable sizes; use `--help` for this page.
20
22
  - `-R`: Recurse into directories.
21
23
  - `-t`: Sort by modification time.