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:

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

Also available in: Unified diff