Revision 1952
Added by Aaron Marcuse-Kubitza over 12 years ago
bin/stop_imports | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# Stops all running imports |
3 | 3 |
|
4 |
self="${BASH_SOURCE[0]}" |
|
5 |
selfDir="$(dirname -- "$self")" |
|
6 |
|
|
7 |
if test "${BASH_LINENO[0]}" = 0; then # was run without initial "." |
|
8 |
echo "Usage: . $self (note initial \".\")"|fold -s >&2 |
|
9 |
return 2 |
|
10 |
fi |
|
11 |
|
|
12 |
for job in $(jobs|grep -F 'make inputs/'|"$selfDir/jobspecs"); do |
|
13 |
kill $job |
|
14 |
done |
|
4 |
stop_imports_main () |
|
5 |
{ |
|
6 |
local self="${BASH_SOURCE[0]}" |
|
7 |
local selfDir="$(dirname -- "$self")" |
|
8 |
|
|
9 |
if test "${BASH_LINENO[@]: -1}" = 0; then # was run without initial "." |
|
10 |
echo "Usage: . $self (note initial \".\")"|fold -s >&2 |
|
11 |
return 2 |
|
12 |
fi |
|
13 |
|
|
14 |
for job in $(jobs|grep -F 'make inputs/'|"$selfDir/jobspecs"); do |
|
15 |
kill $job |
|
16 |
done |
|
17 |
} |
|
18 |
stop_imports_main "$@" |
bin/with_all | ||
---|---|---|
2 | 2 |
# Runs a make target on all inputs at once. |
3 | 3 |
# Creates a job in the calling shell for each process. |
4 | 4 |
|
5 |
self="${BASH_SOURCE[0]}" |
|
6 |
selfDir="$(dirname -- "$self")" |
|
7 |
|
|
8 |
# Was run without initial ".", or with insufficient parameters |
|
9 |
if test "${BASH_LINENO[0]}" = 0 -o "$#" -lt 1; then |
|
10 |
echo "Usage: . $self make_target (note initial \".\")"|fold -s >&2 |
|
11 |
return 2 |
|
12 |
fi |
|
13 |
|
|
14 |
for input in inputs/*/; do |
|
15 |
eval "make ${input}$1 &" |
|
16 |
disown -h "$(jobs|tail -1|"$selfDir/jobspecs")" # ignore SIGHUP |
|
17 |
sleep 2 # wait for initial output so that outputs don't become jumbled |
|
18 |
done |
|
5 |
with_all_main () |
|
6 |
{ |
|
7 |
local self="${BASH_SOURCE[0]}" |
|
8 |
local selfDir="$(dirname -- "$self")" |
|
9 |
|
|
10 |
# Was run without initial ".", or with insufficient parameters |
|
11 |
if test "${BASH_LINENO[@]: -1}" = 0 -o "$#" -lt 1; then |
|
12 |
echo "Usage: . $self make_target (note initial \".\")"|fold -s >&2 |
|
13 |
return 2 |
|
14 |
fi |
|
15 |
|
|
16 |
for input in inputs/*/; do |
|
17 |
eval "make ${input}$1 &" |
|
18 |
disown -h "$(jobs|tail -1|"$selfDir/jobspecs")" # ignore SIGHUP |
|
19 |
sleep 2 # wait for initial output so that outputs don't become jumbled |
|
20 |
done |
|
21 |
} |
|
22 |
with_all_main "$@" |
bin/import_all | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# Imports all inputs at once |
3 | 3 |
|
4 |
self="${BASH_SOURCE[0]}" |
|
5 |
selfDir="$(dirname -- "$self")" |
|
6 |
|
|
7 |
if test "${BASH_LINENO[0]}" = 0; then # was run without initial "." |
|
8 |
echo "Usage: . $self (note initial \".\")"|fold -s >&2 |
|
9 |
return 2 |
|
10 |
fi |
|
11 |
|
|
12 |
. "$selfDir/with_all" import |
|
4 |
import_all_main () |
|
5 |
{ |
|
6 |
local self="${BASH_SOURCE[0]}" |
|
7 |
local selfDir="$(dirname -- "$self")" |
|
8 |
|
|
9 |
if test "${BASH_LINENO[@]: -1}" = 0; then # was run without initial "." |
|
10 |
echo "Usage: . $self (note initial \".\")"|fold -s >&2 |
|
11 |
return 2 |
|
12 |
fi |
|
13 |
|
|
14 |
. "$selfDir/with_all" import |
|
15 |
} |
|
16 |
import_all_main "$@" |
bin/env_password | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# Sets a password environment variable |
3 | 3 |
|
4 |
self="$(readlink -f -- "${BASH_SOURCE[0]}")" |
|
5 |
|
|
6 |
set -o pipefail |
|
7 |
|
|
8 |
store= |
|
9 |
test "$1" = - && { store=1; shift;} |
|
10 |
|
|
11 |
# Was run without initial ".", or with insufficient parameters |
|
12 |
if test "${BASH_LINENO[0]}" = 0 -o "$#" -lt 1; then |
|
13 |
echo "Usage: . $self env_var [desc] (note initial \".\")"|fold -s >&2 |
|
14 |
return 2 |
|
15 |
fi |
|
16 |
|
|
17 |
desc="$2" |
|
18 |
test -n "$desc" || desc="the $1 password" |
|
19 |
|
|
20 |
function trace() { for arg in "$@"; do printf "%q " "$arg"; done; echo;} |
|
21 |
|
|
22 |
function traceSelf() { trace . "$self" - "$@";} |
|
23 |
|
|
24 |
if test -n "$store" -o -z "${!1+t}"; then # env var with name $1 is unset |
|
25 |
if test -n "$store"; then |
|
26 |
echo "[7m To change the saved value for $desc, run: [0m" >&2 |
|
27 |
traceSelf "$@" >&2 |
|
28 |
else |
|
29 |
test -t 2 && ccTty= || ccTty=1 # cc the tty if stderr is a log file |
|
30 |
{ |
|
31 |
echo "[101;97m You must first store $desc. At the shell, run: [39;49m" |
|
32 |
traceSelf "$@" |
|
33 |
}|tee ${ccTty:+/dev/tty} >&2 |
|
4 |
env_password_main () |
|
5 |
{ |
|
6 |
local self="$(readlink -f -- "${BASH_SOURCE[0]}")" |
|
7 |
|
|
8 |
set -o pipefail |
|
9 |
|
|
10 |
local store= |
|
11 |
test "$1" = - && { store=1; shift;} |
|
12 |
|
|
13 |
# Was run without initial ".", or with insufficient parameters |
|
14 |
if test "${BASH_LINENO[@]: -1}" = 0 -o "$#" -lt 1; then |
|
15 |
echo "Usage: . $self env_var [desc] (note initial \".\")"|fold -s >&2 |
|
16 |
return 2 |
|
34 | 17 |
fi |
35 | 18 |
|
36 |
test -z "$store" && return 1 # just direct user how to store password |
|
37 |
read -s -p "Enter $desc: "; echo |
|
38 |
export "$1"="$REPLY" |
|
39 |
fi |
|
19 |
local desc="$2" |
|
20 |
test -n "$desc" || desc="the $1 password" |
|
21 |
|
|
22 |
function trace() { for arg in "$@"; do printf "%q " "$arg"; done; echo;} |
|
23 |
|
|
24 |
function traceSelf() { trace . "$self" - "$@";} |
|
25 |
|
|
26 |
if test -n "$store" -o -z "${!1+t}"; then # env var with name $1 is unset |
|
27 |
if test -n "$store"; then |
|
28 |
echo "[7m To change the saved value for $desc, run: [0m" >&2 |
|
29 |
traceSelf "$@" >&2 |
|
30 |
else |
|
31 |
test -t 2 && ccTty= || ccTty=1 # cc the tty if stderr is a log file |
|
32 |
{ |
|
33 |
echo "[101;97m You must first store $desc. \ |
|
34 |
At the shell, run: [39;49m" |
|
35 |
traceSelf "$@" |
|
36 |
}|tee ${ccTty:+/dev/tty} >&2 |
|
37 |
fi |
|
38 |
|
|
39 |
test -z "$store" && return 1 # just direct user how to store password |
|
40 |
read -s -p "Enter $desc: "; echo |
|
41 |
export "$1"="$REPLY" |
|
42 |
fi |
|
43 |
} |
|
44 |
env_password_main "$@" |
Also available in: Unified diff
Scripts that are meant to be run in the calling shell: Fixed bug where running the script as a program (without initial ".") wouldn't be able to call return in something that was not a function. Converted all code to a <script_name>_main method so that return would work properly again. Converted all variables to local variables.