-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] Cosmetic changes to core/process.py
Also add demo/jobs-builtin.sh, which reminds me of what we have to do for 'jobs' and 'jobs -l'. This is related to issue #360.
- Loading branch information
Andy C
committed
Nov 16, 2021
1 parent
d2796b9
commit cd9786e
Showing
3 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Compare the output of "jobs" in different shells | ||
# | ||
# Usage: | ||
# $SH demo/jobs-builtin.sh <function name> | ||
|
||
set -o nounset | ||
#set -o pipefail | ||
set -o errexit | ||
|
||
# Notes: | ||
# - the formats are consistent, because it's specified by POSIX | ||
# - they use [1] [2] [3] | ||
# - + is the default job for 'fg' and 'bg', which is also %% | ||
# - - is the job that would become the default, which is also %- | ||
# | ||
# "[%d] %c %s %s\n", <job-number>, <current>, <state>, <command> | ||
# | ||
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/jobs.html | ||
# | ||
# TODO: Oil should print this as QSN! So you can parse it. | ||
# | ||
# - dash is the only shell that doesn't show source code; it just shows | for pipe | ||
# - mksh has some weird quoting, like \sleep 1 | ||
# - mksh and zsh doesn't show trailing &, but bash does | ||
# | ||
|
||
show_jobs() { | ||
echo ___ | ||
|
||
# all shells support this long format which shows components of a pipeline | ||
jobs -l | ||
#jobs | ||
} | ||
|
||
myfunc() { | ||
sleep 0.3 | ||
show_jobs | ||
|
||
sleep 0.4 | ||
show_jobs | ||
} | ||
|
||
|
||
demo() { | ||
sleep 1 & sleep 2 & | ||
show_jobs | ||
|
||
{ echo pipe1; sleep 0.5; } | cat & | ||
show_jobs | ||
|
||
myfunc & | ||
|
||
# only bash supports wait -n | ||
if test -n "${BASH_VERSION:-}"; then | ||
wait -n | ||
show_jobs | ||
fi | ||
|
||
wait | ||
show_jobs | ||
|
||
ls | wc -l | ||
show_jobs | ||
} | ||
|
||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters