This commit is contained in:
Raven Scott
2026-04-03 20:33:24 -04:00
parent ae6b7f8652
commit e58a9f99d6
184 changed files with 1636 additions and 109 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ async function run(ctx, argv) {
}
```
No top-level `import` — commands are loaded by the booter via `AsyncFunction` for Bare/Pear compatibility. Use `ctx.vfs`, `ctx.console`, `ctx.b4a`, `ctx.drive`, `bareStdin(ctx)` from the prelude where needed.
No top-level `import` — commands are loaded by the booter via `AsyncFunction` for Bare/Pear compatibility. The concatenated prelude starts with **`/* BARE_OS_BIN_API … */`** so **`scripts/verify-kernel-seeder-parity.mjs`** can verify staged **`kernel/bin/*`**. Use `ctx.vfs`, `ctx.console`, `ctx.b4a`, `ctx.drive`, `bareStdin(ctx)` from the prelude where needed.
## Build
@@ -33,7 +33,7 @@ Or `node packages/bare-os-coreutils/build.mjs`.
**Source of truth:** **`lib/commands.mjs`** — **`COREUTILS_COMMANDS`** (imported by **`build.mjs`** and **`scripts/build-man-db.mjs`**). Each name must have **`man/pages/<name>.json`**.
`awk`, `basename`, `cat`, `chgrp`, `chmod`, `chown`, `cksum`, `clear`, `cp`, `crontab`, `cut`, `date`, `dirname`, `du`, `echo`, `env`, `exit`, `false`, `find`, `getconf`, `grep`, `head`, `hdms`, `help`, `hostname`, `id`, `ln`, `login`, `logout`, `logname`, `ls`, `man`, `mkdir`, `mkfifo`, `mv`, `nl`, `od`, `pathchk`, `printenv`, `printf`, `pwd`, `readlink`, `rm`, `rmdir`, `savevault`, `sed`, `seq`, `sleep`, `sort`, `stat`, `tail`, `tee`, `test`, `time`, `touch`, `tr`, `true`, `tty`, `uname`, `wc`, `which`, `whoami`, `xargs`
`awk`, `basename`, `cat`, `chgrp`, `chmod`, `chown`, `cksum`, `clear`, `cp`, `crontab`, `cut`, `date`, `dirname`, `du`, `echo`, `env`, `exit`, `false`, `find`, `getconf`, `git-pear`, `grep`, `head`, `hdms`, `help`, `hostname`, `id`, `jq`, `ln`, `login`, `logout`, `logname`, `ls`, `man`, `mkdir`, `mkfifo`, `mktemp`, `mv`, `nl`, `od`, `pathchk`, `printenv`, `printf`, `pwd`, `readlink`, `rm`, `rmdir`, `savevault`, `sed`, `seq`, `sleep`, `sort`, `stat`, `tail`, `tee`, `test`, `time`, `touch`, `tr`, `true`, `tty`, `uname`, `wc`, `which`, `whoami`, `xargs`
**`grep`** uses JavaScript **`RegExp`** (and **`-F`** fixed strings); POSIX/GNU-like **subset** (including **`-x`**, **`-m`**, **`-o`** among common flags).
@@ -23,6 +23,7 @@ export const COREUTILS_COMMANDS = [
'false',
'find',
'getconf',
'git-pear',
'grep',
'head',
'hdms',
@@ -38,6 +39,7 @@ export const COREUTILS_COMMANDS = [
'man',
'mkdir',
'mkfifo',
'mktemp',
'mv',
'nl',
'od',
@@ -1,3 +1,4 @@
/* BARE_OS_BIN_API 1.0.0 — bump when staged /bin script semantics change (see developer guide). */
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
function bareStdin(ctx) {
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
@@ -0,0 +1,10 @@
{
"name": "git-pear",
"section": 1,
"title": "Git-in-Pear hints",
"synopsis": ["git-pear help"],
"description": "Prints short documentation for git+pear remotes (gip-transport / gip-remote). See packages/bare-os-coreutils/src/git-pear.js.",
"options": [],
"keywords": ["git", "pear", "gip", "bare-os"],
"examples": [{ "caption": "help", "code": "git-pear help" }]
}
@@ -0,0 +1,17 @@
{
"name": "mktemp",
"section": 1,
"title": "create a temporary file or directory",
"synopsis": [
"mktemp [OPTION] [TEMPLATE]"
],
"description": "Creates a file or directory under /tmp (or absolute TEMPLATE). Replaces XXXXXX with random characters. See packages/bare-os-coreutils/src/mktemp.js.",
"options": [
{ "flag": "-d", "meaning": "create a directory" }
],
"keywords": ["mktemp", "bare-os", "coreutils"],
"examples": [
{ "caption": "file", "code": "mktemp tmp.XXXXXX" },
{ "caption": "dir", "code": "mktemp -d dir.XXXXXX" }
]
}
+1 -1
View File
@@ -55,7 +55,7 @@ async function run(ctx, argv) {
const rest = []
for (let i = 1; i < argv.length; i++) {
const a = argv[i]
if (a === '-maxdepth' && argv[i + 1]) {
if ((a === '-maxdepth' || a === '-depth') && argv[i + 1]) {
maxDepth = Number.parseInt(argv[++i], 10)
continue
}
@@ -0,0 +1,19 @@
async function run(ctx, argv) {
const sub = argv[1]
if (sub === 'help' || sub === undefined) {
ctx.console.log(`git-pear — Git-in-Pear helpers (gip-transport / gip-remote)
Remote form: git+pear://… (see Holepunch gip-transport + gip-remote).
Typical flow:
git remote add origin 'git+pear://<key-or-link>'
git push origin main
Pear app channel metadata for images: set BARE_OS_PEAR_CHANNEL / BARE_OS_PEAR_RELEASE on the host.
`)
ctx.exitCode = 0
return
}
ctx.console.error('git-pear: unknown subcommand; use git-pear help')
ctx.exitCode = 1
}
+26
View File
@@ -0,0 +1,26 @@
async function run(ctx, argv) {
let wantDir = false
/** @type {string | null} */
let template = null
for (let i = 1; i < argv.length; i++) {
const a = argv[i]
if (a === '-d') wantDir = true
else if (!a.startsWith('-')) template = a
}
const rnd = () =>
Math.random().toString(36).slice(2, 10) +
Math.random().toString(36).slice(2, 6)
let rel = template || 'tmp.XXXXXX'
if (rel.includes('XXXXXX')) rel = rel.replace(/XXXXXX/g, rnd())
else rel = `${rel.replace(/\/+$/, '')}.${rnd()}`
const full = rel.startsWith('/') ? rel : `/tmp/${rel.replace(/^\/+/, '')}`
try {
if (wantDir) await ctx.vfs.mkdir(full, { recursive: false })
else await ctx.vfs.writeFile(full, ctx.b4a.from(''))
ctx.console.log(full)
ctx.exitCode = 0
} catch (e) {
ctx.console.error('mktemp: ' + ((e && e.message) || e))
ctx.exitCode = 1
}
}