projects
/
platform
/
upstream
/
bash.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
dafbac5a8f9edd9097d37b5e393f009a65b459f5
[platform/upstream/bash.git]
/
examples
/
functions
/
notify.bash
1
trap _notify CHLD
2
NOTIFY_ALL=false
3
unset NOTIFY_LIST
4
unalias false
5
6
false()
7
{
8
return 1
9
}
10
11
_notify ()
12
{
13
local i j
14
local newlist=
15
16
if $NOTIFY_ALL
17
then
18
return # let bash take care of this itself
19
elif [ -z "$NOTIFY_LIST" ]; then
20
return
21
else
22
set -- $NOTIFY_LIST
23
for i in "$@"
24
do
25
j=$(jobs -n %$i)
26
if [ -n "$j" ]; then
27
echo "$j"
28
jobs -n %$i >/dev/null
29
else
30
newlist="newlist $i"
31
fi
32
done
33
NOTIFY_LIST="$newlist"
34
fi
35
}
36
37
notify ()
38
{
39
local i j
40
41
if [ $# -eq 0 ]; then
42
NOTIFY_ALL=:
43
set -b
44
return
45
else
46
for i in "$@"
47
do
48
# turn a valid job spec into a job number
49
j=$(jobs $i)
50
case "$j" in
51
[*) j=${j%%]*}
52
j=${j#[}
53
NOTIFY_LIST="$NOTIFY_LIST $j"
54
;;
55
esac
56
done
57
fi
58
}