blob: 0ea480b80633ed8afa3c78dbd8d48fc5ee806ec0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/env bun
import { realpathSync } from "node:fs";
import { basename } from "node:path";
import { commandNames } from "../src/shared/catalog.js";
import { main } from "../src/shared/runtime.js";
globalThis[Symbol.for("bnu.cli")] = true;
let invokedPath = Bun.argv[1];
try {
if (process.env._ && realpathSync(process.env._) === realpathSync(Bun.argv[1])) invokedPath = process.env._;
} catch {
// Fall back to Bun's resolved script path when the shell-provided path is not usable.
}
const invokedAs = basename(invokedPath).replace(/\.js$/, "");
const argv = invokedAs === "bnu"
? Bun.argv.slice(2)
: commandNames.includes(invokedAs)
? [invokedAs, ...Bun.argv.slice(2)]
: ["coreutils", `--coreutils-prog=${invokedAs}`, ...Bun.argv.slice(2)];
process.exit(await main(argv));
|