]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/functions
f3a4096b51b00238efec9d8927b2555a7f2538aa
[config/dotfiles.git] / shell / functions
1 # Shell functions useful to all shells.
2
3
4 # Helper function to print debug information if $DEBUG is not empty.
5 #
6 # Doesn't fit perfectly in this file, but this is the best place to make it
7 # available everywhere.
8 source_debug() {
9     if [ x$DEBUG != x ]; then
10         echo "$@"
11     fi
12 }
13
14 # Source $1 if it exists. And $1.local if it exists as well.
15 source_config() {
16     source_debug "source_config(): $1"
17
18     if [ -f $1 ]; then
19         source_debug ". $1"
20         . $1
21     fi
22
23     if [ -f $1.local ]; then
24         source_debug ". $1.local"
25         . $1.local
26     fi
27 }
28
29 # vim: ft=sh