Project

General

Profile

« Previous | Next » 

Revision 1952

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.

View differences:

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 "$@"

Also available in: Unified diff