new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Bun · all subjects

runtime/shell

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Bun Shell $ function basic usage

Bun Shell is a cross-platform bash-like shell built into Bun. The $ function is a tagged template literal imported from the 'bun' package that runs shell commands from JavaScript and TypeScript. The $ function returns a promise that resolves with the command's output. Example: await $`echo Hello, world!` returns "Hello, world!".

$ function text() method

The $ function's result has a text() method that can be called to get the command output as text. Example: const output = await $`ls -l`.text(); will return the output as a string.

$ function lines() method

The $ function's result has a lines() method that can be called to iterate over each line of the command output. The lines() method returns an async iterable that can be used in a for-await loop. Example: for await (const line of $`ls -l`.lines()) { console.log(line); }

Importing $ from bun package

To use the $ function for running shell commands, import it from the 'bun' package: import { $ } from "bun";

$ function shell command example

The $ function is used as a tagged template literal to run shell commands. Example: await $`echo Hello, world!`; runs the echo command.

$ function text() method example

To get the output of a shell command as text: import { $ } from "bun"; const output = await $`ls -l`.text(); console.log(output);

$ function lines() method example

To iterate over each line of a shell command's output: import { $ } from "bun"; for await (const line of $`ls -l`.lines()) { console.log(line); }

Give your agent this brain