buninu 0.3.0 → 0.3.1
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.
- package/README.md +21 -0
- package/apps/bunmsh/CHANGELOG.md +262 -0
- package/apps/bunmsh/LICENSE +21 -0
- package/apps/bunmsh/LICENSE-MKSH +295 -0
- package/apps/bunmsh/PORTING.md +192 -0
- package/apps/bunmsh/README.md +801 -0
- package/apps/bunmsh/bunmsh +7 -0
- package/apps/bunmsh/bunshell.md +61 -0
- package/apps/bunmsh/help/README.md +1945 -0
- package/apps/bunmsh/help/alias.md +22 -0
- package/apps/bunmsh/help/basename.md +38 -0
- package/apps/bunmsh/help/builtin.md +25 -0
- package/apps/bunmsh/help/bun.md +27 -0
- package/apps/bunmsh/help/bunmsh.md +47 -0
- package/apps/bunmsh/help/cat.md +31 -0
- package/apps/bunmsh/help/catfancy.md +35 -0
- package/apps/bunmsh/help/cd.md +22 -0
- package/apps/bunmsh/help/chmod.md +27 -0
- package/apps/bunmsh/help/clear.md +21 -0
- package/apps/bunmsh/help/colon.md +22 -0
- package/apps/bunmsh/help/command.md +27 -0
- package/apps/bunmsh/help/cp.md +28 -0
- package/apps/bunmsh/help/cut.md +25 -0
- package/apps/bunmsh/help/date.md +25 -0
- package/apps/bunmsh/help/dirname.md +25 -0
- package/apps/bunmsh/help/echo.md +25 -0
- package/apps/bunmsh/help/env.md +27 -0
- package/apps/bunmsh/help/eval.md +22 -0
- package/apps/bunmsh/help/exec.md +22 -0
- package/apps/bunmsh/help/exit.md +21 -0
- package/apps/bunmsh/help/export.md +22 -0
- package/apps/bunmsh/help/false.md +22 -0
- package/apps/bunmsh/help/find.md +33 -0
- package/apps/bunmsh/help/getopts.md +28 -0
- package/apps/bunmsh/help/grep.md +34 -0
- package/apps/bunmsh/help/head.md +27 -0
- package/apps/bunmsh/help/kill.md +27 -0
- package/apps/bunmsh/help/ln.md +28 -0
- package/apps/bunmsh/help/ls.md +37 -0
- package/apps/bunmsh/help/lsbun.md +29 -0
- package/apps/bunmsh/help/lsfancy.md +37 -0
- package/apps/bunmsh/help/md5sum.md +21 -0
- package/apps/bunmsh/help/mkdir.md +27 -0
- package/apps/bunmsh/help/mktemp.md +26 -0
- package/apps/bunmsh/help/mv.md +26 -0
- package/apps/bunmsh/help/print.md +30 -0
- package/apps/bunmsh/help/printf.md +25 -0
- package/apps/bunmsh/help/pwd.md +21 -0
- package/apps/bunmsh/help/read.md +27 -0
- package/apps/bunmsh/help/readonly.md +27 -0
- package/apps/bunmsh/help/realpath.md +21 -0
- package/apps/bunmsh/help/rm.md +33 -0
- package/apps/bunmsh/help/rmdir.md +27 -0
- package/apps/bunmsh/help/sed.md +29 -0
- package/apps/bunmsh/help/seq.md +29 -0
- package/apps/bunmsh/help/serve.md +50 -0
- package/apps/bunmsh/help/set.md +26 -0
- package/apps/bunmsh/help/sha256sum.md +21 -0
- package/apps/bunmsh/help/shift.md +23 -0
- package/apps/bunmsh/help/sleep.md +25 -0
- package/apps/bunmsh/help/sort.md +29 -0
- package/apps/bunmsh/help/source.md +23 -0
- package/apps/bunmsh/help/tab.md +30 -0
- package/apps/bunmsh/help/tac.md +29 -0
- package/apps/bunmsh/help/tail.md +27 -0
- package/apps/bunmsh/help/tee.md +25 -0
- package/apps/bunmsh/help/test.md +30 -0
- package/apps/bunmsh/help/time.md +29 -0
- package/apps/bunmsh/help/touch.md +26 -0
- package/apps/bunmsh/help/tr.md +26 -0
- package/apps/bunmsh/help/true.md +22 -0
- package/apps/bunmsh/help/type.md +21 -0
- package/apps/bunmsh/help/umask.md +22 -0
- package/apps/bunmsh/help/unalias.md +28 -0
- package/apps/bunmsh/help/uname.md +31 -0
- package/apps/bunmsh/help/unset.md +28 -0
- package/apps/bunmsh/help/wc.md +27 -0
- package/apps/bunmsh/help/whence.md +26 -0
- package/apps/bunmsh/help/which.md +41 -0
- package/apps/bunmsh/help/yes.md +23 -0
- package/apps/bunmsh/package.json +26 -0
- package/apps/bunmsh/serve.js +468 -0
- package/apps/bunmsh/single-exe/README.md +402 -0
- package/apps/bunmsh/single-exe/assetsHelper.js +371 -0
- package/apps/bunmsh/single-exe/assetsLoader.mjs +85 -0
- package/apps/bunmsh/single-exe/assetsPacker.js +218 -0
- package/apps/bunmsh/single-exe/compiled.js +527 -0
- package/apps/bunmsh/single-exe/entry.mjs +17 -0
- package/apps/bunmsh/src/cat-fancy.js +117 -0
- package/apps/bunmsh/src/cat-operands.js +31 -0
- package/apps/bunmsh/src/completion.js +247 -0
- package/apps/bunmsh/src/environment.js +61 -0
- package/apps/bunmsh/src/fancy-ls.js +186 -0
- package/apps/bunmsh/src/find.js +119 -0
- package/apps/bunmsh/src/history.js +198 -0
- package/apps/bunmsh/src/main.js +776 -0
- package/apps/bunmsh/src/mouse.js +103 -0
- package/apps/bunmsh/src/shell.js +3557 -0
- package/apps/bunmsh/test/catfancy.test.js +102 -0
- package/apps/bunmsh/test/reference-source.sh +1 -0
- package/apps/bunmsh/test/reference.test.js +677 -0
- package/apps/bunmsh/test/serve/README.md +3 -0
- package/apps/bunmsh/test/serve/bad.json +1 -0
- package/apps/bunmsh/test/serve/data.json +1 -0
- package/apps/bunmsh/test/serve/data.json5 +1 -0
- package/apps/bunmsh/test/serve/data.jsonc +2 -0
- package/apps/bunmsh/test/serve/data.jsonl +2 -0
- package/apps/bunmsh/test/serve/data.ndjson +1 -0
- package/apps/bunmsh/test/serve/data.toml +3 -0
- package/apps/bunmsh/test/serve/data.ts +15 -0
- package/apps/bunmsh/test/serve/data.xml +1 -0
- package/apps/bunmsh/test/serve/data.yaml +3 -0
- package/apps/bunmsh/test/serve/data.yml +1 -0
- package/apps/bunmsh/test/serve.test.js +241 -0
- package/apps/bunmsh/test/shell.test.js +1778 -0
- package/apps/bunmsh/test/t.sh +12 -0
- package/bin/init.js +11 -3
- package/package.json +2 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# mksh to Bun porting status
|
|
2
|
+
|
|
3
|
+
This document tracks detailed implementation boundaries. bunmsh 0.1.8 is a
|
|
4
|
+
clean JavaScript shell inspired by mksh's user-facing model; it is useful as a
|
|
5
|
+
command shell, but it is not a drop-in mksh or fully POSIX-compatible shell.
|
|
6
|
+
The README describes user-facing commands and flags. This file focuses on
|
|
7
|
+
semantic coverage, architecture, platform behaviour, and remaining work.
|
|
8
|
+
|
|
9
|
+
## Implemented core
|
|
10
|
+
|
|
11
|
+
| Area | Current status |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| CLI | Interactive mode, stdin, script files, `-c`, already-quoted `-cc`, `-i`, `--mouse`, `--builtin-only`, help, version, README display, and standalone build entry points |
|
|
14
|
+
| JavaScript | Raw lines beginning with `Bun.` bypass shell parsing and use awaited JavaScript `eval`; this also works inside command substitution and script files |
|
|
15
|
+
| Lexing and lists | Comments at word boundaries, single/double quotes, escapes, newline and `;` lists, `&&`, `||`, pipelines, and `!` negation |
|
|
16
|
+
| Compound grammar | One-line and multiline `if`/`elif`/`else`, `case`, `while`, `until`, `for`, shell functions, and parenthesised subshells |
|
|
17
|
+
| Expansion | Parameters and common POSIX operators, mksh-style replacement, command substitution, legacy backticks, arithmetic expansion, IFS field splitting, tilde expansion, brace alternatives, and standard pathname globs |
|
|
18
|
+
| Redirection | Streamed stdin/stdout/stderr truncate and append redirects, `<<`/`<<-` here-documents, `<<<` here-strings, redirects on pipelines and compound commands, and common descriptor duplication such as `2>&1` |
|
|
19
|
+
| Pipelines | Stages run concurrently with Web Streams and `Bun.spawn`; large output is not collected, early-closing consumers stop upstream producers, and pipeline status comes from the final stage |
|
|
20
|
+
| Commands | Aliases, functions, regular builtins, PATH lookup, system-first fallback builtins, Bun Shell fallbacks, explicit paths, and `command`/`builtin` lookup controls |
|
|
21
|
+
| State | cwd tabs with shared shell state, environment and assignments, positional arguments, readonly names, aliases, functions, last/exit status, and pipeline state isolation |
|
|
22
|
+
| Interactive | Readline editing, saved/Bash/Fish history import, automatic append-only history save (concurrent-session-safe, every 60s/on exit/on SIGTERM/SIGHUP) plus manual `tab s`/`tab save`/`tab s d` control, Up/Down recall, command/file completion, ghost suggestions, keyboard shortcuts, optional SGR mouse interaction, terminal-aware prompt layout, `PS2` continuation prompting for here-documents/open quotes/unfinished compound bodies, and interactive Ctrl-C/Ctrl-D/SIGTERM/SIGHUP handling |
|
|
23
|
+
| Platforms | Forward-slash shell paths with native conversion on Windows, platform PATH delimiters, Windows executable suffix handling, Linux/Android dynamic-linker re-execution, and inherited `LD_LIBRARY_PATH` |
|
|
24
|
+
| Packaging | Source execution and standalone Bun executables, including compiled self-spawn paths used by pipelines and reflected `bunmsh` commands |
|
|
25
|
+
|
|
26
|
+
The automated suite compares core expansion, builtins, grep/sed behaviour,
|
|
27
|
+
pipelines, and redirects with `/bin/sh` or system utilities where their intended
|
|
28
|
+
semantics overlap. Platform-specific behaviour also has focused unit and
|
|
29
|
+
pseudo-terminal tests.
|
|
30
|
+
|
|
31
|
+
## Current semantic boundaries
|
|
32
|
+
|
|
33
|
+
### Grammar and execution
|
|
34
|
+
|
|
35
|
+
- Background jobs (`&`), job control, coprocesses, and asynchronous command
|
|
36
|
+
lists are not implemented.
|
|
37
|
+
- Brace command groups, `select`, arithmetic commands, and `[[ ... ]]` are
|
|
38
|
+
not implemented.
|
|
39
|
+
- Functions and subshells cover practical cases but do not yet reproduce every
|
|
40
|
+
mksh scoping, local-variable, trap, and diagnostic edge case.
|
|
41
|
+
- Pipelines isolate builtin/function state through subprocess copies. Changes
|
|
42
|
+
made by a pipeline stage do not mutate the parent shell, matching the common
|
|
43
|
+
shell model but not every mksh optimisation detail.
|
|
44
|
+
- There is no process-group based foreground/background job-control layer yet.
|
|
45
|
+
Foreground TUI commands do receive the terminal directly while bunmsh pauses
|
|
46
|
+
readline and temporarily disables its own mouse reporting.
|
|
47
|
+
|
|
48
|
+
### Expansion
|
|
49
|
+
|
|
50
|
+
- Common parameter defaults, alternatives, lengths, trimming, and replacement
|
|
51
|
+
are supported, but arrays, associative arrays, namerefs, mksh transforms,
|
|
52
|
+
and `${| ...; }` are not.
|
|
53
|
+
- Standard `*`, `?`, and bracket pathname patterns are supported. Extended glob
|
|
54
|
+
operators and process substitution are not.
|
|
55
|
+
- Brace alternatives are supported; the implementation is not a complete
|
|
56
|
+
reproduction of every mksh brace-range and nested edge case.
|
|
57
|
+
- Arithmetic expansion supports shell variables and common integer operators,
|
|
58
|
+
not the complete mksh arithmetic language.
|
|
59
|
+
|
|
60
|
+
### Redirection and processes
|
|
61
|
+
|
|
62
|
+
- `<`, `>`, `>>`, `2>`, `2>>`, `<<`/`<<-` here-documents, `<<<` here-strings,
|
|
63
|
+
and common output descriptor duplication are implemented with streaming I/O.
|
|
64
|
+
An unquoted and unescaped heredoc delimiter expands parameters, command, and
|
|
65
|
+
arithmetic substitution in the body like a double-quoted string; a quoted or
|
|
66
|
+
backslash-escaped delimiter leaves the body literal. Like dash and bash, a
|
|
67
|
+
script that ends before a heredoc's terminator line appears uses whatever
|
|
68
|
+
was read as the body instead of raising a syntax error.
|
|
69
|
+
- `<<<word` expands `word` as mksh's `DOHERESTR | DOSCALAR` do: parameter,
|
|
70
|
+
command, and arithmetic substitution run, but there is no field splitting,
|
|
71
|
+
pathname expansion, or tilde expansion, and a trailing newline is appended.
|
|
72
|
+
It follows the same dash/`/bin/sh` comparison harness as everything else in
|
|
73
|
+
this codebase, except `<<<` itself, since dash does not implement it.
|
|
74
|
+
- Arbitrary descriptor allocation/manipulation, descriptor variables,
|
|
75
|
+
heredocs targeting a descriptor other than stdin, and every ordering edge
|
|
76
|
+
case remain incomplete.
|
|
77
|
+
- External processes use `Bun.spawn`; regular and fallback builtins may execute
|
|
78
|
+
in-process or in a self-spawned bunmsh pipeline child depending on streaming
|
|
79
|
+
and state-isolation requirements.
|
|
80
|
+
- The reflected `bunmsh` launcher preserves dynamic-linker invocation on Linux
|
|
81
|
+
and Android for `ld-linux`, `ld-musl`, `linker`, and `linker64` forms, and
|
|
82
|
+
preserves `LD_LIBRARY_PATH`. Unusual launch wrappers may still require
|
|
83
|
+
additional platform handling.
|
|
84
|
+
|
|
85
|
+
### Signals and job control
|
|
86
|
+
|
|
87
|
+
- Interactive bunmsh catches SIGINT instead of allowing Ctrl-C to terminate
|
|
88
|
+
the shell. At the prompt it abandons the current edit and starts a fresh
|
|
89
|
+
prompt with status 130. A foreground `serve` handles the same signal by
|
|
90
|
+
stopping its server, returning status 130, and handing control back to the
|
|
91
|
+
interactive loop.
|
|
92
|
+
- Ctrl-D on an empty readline input sends EOF and exits the interactive shell.
|
|
93
|
+
This is deliberately distinct from Ctrl-C, following the same high-level
|
|
94
|
+
editor/main-loop separation used by mksh.
|
|
95
|
+
- The current implementation handles SIGINT through readline while editing and
|
|
96
|
+
through a process signal listener while a foreground operation owns the
|
|
97
|
+
terminal. It does not yet have mksh's general pending-signal table and safe
|
|
98
|
+
trap checkpoints.
|
|
99
|
+
- There is no `trap` builtin or support for user handlers for signals, `EXIT`,
|
|
100
|
+
or `ERR`. Signal handlers therefore cannot yet execute shell source, be
|
|
101
|
+
listed, ignored, reset, or inherited with POSIX/mksh semantics.
|
|
102
|
+
- Status 130 is defined for an interrupted `serve`, and its SIGTERM path uses
|
|
103
|
+
143. Signal-derived statuses are not yet normalised consistently for every
|
|
104
|
+
external command, builtin, pipeline stage, and command substitution.
|
|
105
|
+
- Interactive mode catches SIGTERM and SIGHUP while waiting at the prompt: it
|
|
106
|
+
flushes history (see the history-saving row in the Implemented core table)
|
|
107
|
+
and exits with the conventional 128+signal status. While a foreground
|
|
108
|
+
command owns the terminal, receiving either only flushes history
|
|
109
|
+
immediately — it does not stop that command, since there is no
|
|
110
|
+
process-group job-control layer yet to do that safely (see below); the
|
|
111
|
+
shell actually exits once the command finishes on its own. Neither has
|
|
112
|
+
mksh's complete interactive policies otherwise; SIGQUIT does not have a
|
|
113
|
+
handler at all; SIGCHLD does not maintain a job table; and SIGWINCH is not
|
|
114
|
+
integrated into a general signal subsystem.
|
|
115
|
+
- Terminal control characters are currently mediated by Bun readline. bunmsh
|
|
116
|
+
does not read termios `VINTR`, `VQUIT`, or `VEOF`, so remapping those keys
|
|
117
|
+
with `stty` is not guaranteed to match mksh.
|
|
118
|
+
- Long-running JavaScript builtins need command-specific cancellation today.
|
|
119
|
+
`serve` implements it, while there is not yet a common abort context that can
|
|
120
|
+
interrupt every asynchronous builtin safely.
|
|
121
|
+
- Pipeline shutdown handles practical early-closing consumers and stops
|
|
122
|
+
upstream producers, but SIGPIPE status/disposition is not yet integrated
|
|
123
|
+
with a full process-group and job-control model.
|
|
124
|
+
- Background execution, process groups, terminal foreground ownership, job
|
|
125
|
+
tables, `jobs`, `fg`, `bg`, `wait`, and Ctrl-Z/SIGTSTP handling remain
|
|
126
|
+
unimplemented. SIGTTIN and SIGTTOU policies consequently remain absent too.
|
|
127
|
+
|
|
128
|
+
### Builtins and utilities
|
|
129
|
+
|
|
130
|
+
- The README's builtin tables are the source of truth for currently supported
|
|
131
|
+
command flags. Most implementations intentionally cover common usage rather
|
|
132
|
+
than every POSIX, GNU, or mksh option.
|
|
133
|
+
- `printf`, `print`, `read`, `test`, `getopts`, `kill`, `sed`, `grep`, `find`,
|
|
134
|
+
and other utilities have documented subsets and are not complete clones.
|
|
135
|
+
- Fallback builtins normally yield to an executable of the same name in PATH.
|
|
136
|
+
`builtin NAME` forces bunmsh's implementation; builtin-only mode suppresses
|
|
137
|
+
direct PATH dispatch while the explicit `which` query still searches PATH.
|
|
138
|
+
- Bun Shell fallback behaviour is version-dependent. See
|
|
139
|
+
[bunshell.md](bunshell.md) for the tested compatibility snapshot.
|
|
140
|
+
|
|
141
|
+
### Interactive behaviour
|
|
142
|
+
|
|
143
|
+
- History is loaded at startup and saved automatically (every 60s and once
|
|
144
|
+
more on exit), appending only this session's own new commands to a JSON
|
|
145
|
+
Lines file — never rewriting it — so concurrent bunmsh sessions saving
|
|
146
|
+
around the same time cannot overwrite each other's history. `tab s`/
|
|
147
|
+
`tab save` trigger that same append immediately; `tab s d`/`tab save dedupe`
|
|
148
|
+
is a separate, explicit whole-file rewrite that drops duplicates and
|
|
149
|
+
reports if another session's write raced it. A pre-existing history file in
|
|
150
|
+
bunmsh's older single-JSON-array format is read correctly and silently
|
|
151
|
+
upgraded to JSON Lines the next time anything is saved. `fc` is not
|
|
152
|
+
implemented.
|
|
153
|
+
- Completion uses a periodically refreshed sorted PATH index plus live cwd file
|
|
154
|
+
reads. It is practical rather than a byte-for-byte mksh completion engine.
|
|
155
|
+
- Ghost suggestions use imported/saved history and filesystem matches after
|
|
156
|
+
filtering terminal control characters.
|
|
157
|
+
- Full Emacs/Vi editing-mode compatibility, user-defined key bindings, and
|
|
158
|
+
programmable completion are not yet implemented. `PS2` continuation
|
|
159
|
+
prompting (here-documents, open quotes/substitutions, unfinished compound
|
|
160
|
+
bodies) is implemented; see the Implemented core table above.
|
|
161
|
+
- Mouse tracking is opt-in because terminal application tracking interferes
|
|
162
|
+
with normal scrollback in Termux, xterm, and similar terminals.
|
|
163
|
+
|
|
164
|
+
### Platform scope
|
|
165
|
+
|
|
166
|
+
- Linux, Android/Termux, macOS, and Windows are the intended platforms. Windows
|
|
167
|
+
users see forward slashes at the shell layer; bunmsh converts executable and
|
|
168
|
+
filesystem paths at native API boundaries.
|
|
169
|
+
- When Windows does not define `HOME`, bunmsh derives it from `USERPROFILE` or
|
|
170
|
+
`HOMEDRIVE` plus `HOMEPATH`, so `cd`, `~`, and prompt home shortening use the
|
|
171
|
+
same user directory conventions as history storage.
|
|
172
|
+
- Prompt home shortening treats Android's `/data/data/PACKAGE` and
|
|
173
|
+
`/data/user/0/PACKAGE` app-sandbox paths as equivalent, while preserving the
|
|
174
|
+
actual cwd spelling used for filesystem operations.
|
|
175
|
+
- Windows command discovery recognises common executable suffixes internally;
|
|
176
|
+
full `PATHEXT` emulation is intentionally not implemented.
|
|
177
|
+
- OS/2, EBCDIC, MirBSD-specific, and legacy lksh modes are out of scope.
|
|
178
|
+
|
|
179
|
+
## Remaining major work
|
|
180
|
+
|
|
181
|
+
1. Background jobs, process groups, complete signal-status handling, traps,
|
|
182
|
+
general builtin cancellation, and `jobs`/`fg`/`bg`/`wait`.
|
|
183
|
+
2. Shell options such as `errexit`, `nounset`, `pipefail`, `xtrace`, and POSIX
|
|
184
|
+
mode, plus startup/login/restricted-shell files and modes.
|
|
185
|
+
3. Brace groups, `[[ ... ]]`, arithmetic commands,
|
|
186
|
+
extended globs, process substitution, and fuller mksh expansion semantics.
|
|
187
|
+
4. Arrays, associative arrays, namerefs, `typeset`/scope semantics, and more
|
|
188
|
+
complete special builtins.
|
|
189
|
+
5. Programmable completion, multiline editing, editing modes, key bindings,
|
|
190
|
+
`fc`, and automatic history policy.
|
|
191
|
+
6. Broader POSIX conformance testing, mksh `check.t` coverage, exact diagnostics,
|
|
192
|
+
and exit-status compatibility for edge cases.
|