Skip to main content

Command line

Expressions and files

-e evaluates one expression. Quote it to protect spaces and glyphs from the shell.

bpl -e '+/ι10'       # 45

Pass a UTF-8 BPL file to run it as one program. Its statements run in order, names persist throughout the file, and the first error ends the run.

bpl lesson.bpl

The result of an expression is displayed. An assignment displays nothing. Use ⎕← for explicit output. bpl writes each output immediately, without waiting for the rest of the source. Diagnostics go to stderr and include source locations.

To run a file as a script, start it with #!/usr/bin/env bpl. bpl ignores a first line that starts with #!.

Pipes

When you pipe input to bpl with no arguments, bpl behaves like the REPL without prompts. Names persist between lines, and an error in one line does not stop the lines after it.

printf 'v←ι10\n+/v\n' | bpl

- reads all of stdin first, then runs it as it runs a file.

printf 'v←ι10\n+/v\n' | bpl -

When the program that reads the output closes the pipe, bpl stops the evaluation and exits with status 0.

A program run with -e or from a file can read standard input through ⎕ and •nget "-". This program parses piped CSV:

printf 'name,qty\npen,2\ncup,5\n' | bpl -e '+/(•csv •nget "-").qty'   # 7ₓ

When you pass -, or pipe input without arguments, the program comes from standard input. Reading ⎕ or •nget "-" then raises an IO error. In the interactive REPL, reading ⎕ gives a line from the terminal. See ⎕.

Use actual glyphs in files, pipes and -e; backtick names are a REPL input method.

Other modes

Command Mode
bpl Interactive REPL when connected to a terminal
bpl --help Usage
bpl --version Version
bpl --worker JSON-lines requests with deadlines and interruption
bpl --costs PATH Times the cases in a speed file in the format of basedpl’s tests/speed/*.bpl, or in a directory of them, as the speed test does. Prints each cost with this machine’s budget, then each case still over its budget after the retries, marked over. A case over its budget leaves the exit status at 0

See process interfaces for machine-readable output. The exit status is 0 on success, 1 after an evaluation or I/O error, and 2 for invalid command arguments. An error doesn’t discard the output written before it.