Jobs and outcomes
Background jobsPermalink to Background jobs#
End a command line with & to run it in the background. Shale gives each job a number and comes straight back to the prompt. Type jobs to see what's running, and write a job's number after a percent sign to refer to it.
~/project $ sleep 300 &
~/project $ sleep 200 &
~/project $ jobs
[1] running sleep 300
[2] running sleep 200
~/project $ kill %1A job that finishes leaves the list without a message.
Stopping and continuingPermalink to Stopping and continuing#
Press C-z while a command runs in the foreground to stop it. Shale takes back the terminal and prints a line with the job's number, the word stopped and the command. From there:
fgbrings the newest job back to the foreground, andfg %2brings job 2;bglets a stopped job carry on in the background;kill %1ends job 1, continuing it first if it's stopped.
The kill builtin takes job numbers only. To signal a process by its ID, run the kill program by its full path, such as /usr/bin/kill.
When you leave Shale, it sends every job you started a hangup signal, the way closing a terminal would, and ends any job still running a moment later.
OutcomesPermalink to Outcomes#
Every command you run in the foreground ends with an outcome: how it ended and how long it took. When the outcome is a failure, Shale prints it as a result line under the output, as The prompt describes. To see the last outcome again, with the exact time, type ,last:
~/project $ grep plumber README.md
✗ exited 1 · 0s
~/project $ ,last
grep: exited 1 (0.004s)A pipeline fails when any of its commands fails, and it reports the status of the first command that failed, counting from the left. That's close to Bash with pipefail set, which reports the last failure instead. One exception: a command that stops because the command reading its output finished first, like yes in yes | head -n 1, doesn't count as a failure when that reader succeeded. Only the reader decides this: in yes | head -n 1 | sh -c 'cat >/dev/null; exit 7', yes doesn't count, and the pipeline fails with status 7, from the last command.
~/project $ grep plumber README.md | sort
✗ exited 1 · 0sA program that calls Shale can get each command's status in a pipeline as JSON; to learn how, read Shale outside the prompt.