Skip to content

sh

run shell commands from a script file

NAME
    sh - run shell commands from a script file

SYNOPSIS
    sh file

DESCRIPTION
    Reads `file` (a text file of shell command lines) and runs each line
    exactly as if you had typed it at the prompt: built-ins, /bin programs,
    and redirection/pipes (>, <, |) all work. At end of file, control returns
    to the interactive prompt.

    sh is a shell built-in, not a /bin program. The script is streamed a line
    at a time (no size cap), so it may be any length -- each dispatched
    command uses the file streams itself while sh's read position is saved and
    restored around it. Lines end with CR, LF, or CRLF; by convention P8X
    scripts use LF (the Unix line ending, as EDIT writes) and are named with
    a .sh suffix (e.g. `sh build.sh`).

    Caveat: a script line may not use the `< redirect` -- input redirection
    and the script stream share the same buffer (IBUF).

    To rebuild a command from source on the machine, prefer the `make` built-in
    over a hand-written sh script: each /src source dir ships a real Makefile
    (`cd /src/commands/c && make pwd`). sh is for ad-hoc command sequences. A
    build sequence for a C command is just:

        cc /src/commands/c/pwd.c >T.ASM
        asm T.ASM /src/commands/c/bin/pwd.bin

    and for a hand-assembled command (asm resolves ;#use from /lib):

        asm /src/commands/asm/cat.asm /src/commands/asm/bin/cat.bin

EXAMPLES
    sh build            run the commands in the file `build`

SEE ALSO
    make, cc, asm, run, edit

See also: make, cc, asm, run, edit

The text of man sh on P8X (os/man/sh in the repository). All commands