]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/functions
shell/dircolors: add more README file names
[config/dotfiles.git] / shell / functions
1 # Shell functions useful to all shells.
2
3 # Copyright (C) 2011-2012  Simon Ruderich
4 #
5 # This file is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this file.  If not, see <http://www.gnu.org/licenses/>.
17
18
19 # Helper function to print debug information if $DEBUG is not empty.
20 #
21 # Doesn't fit perfectly in this file, but this is the best place to make it
22 # available everywhere.
23 source_debug() {
24     if test "x$DEBUG" != x; then
25         echo "$@"
26     fi
27 }
28
29 # Source $1 if it exists. And $1.local if it exists as well.
30 source_config() {
31     source_debug "source_config(): $1"
32
33     if test -f "$1"; then
34         source_debug ". $1"
35         . "$1"
36     fi
37
38     if test -f "$1.local"; then
39         source_debug ". $1.local"
40         . "$1.local"
41     fi
42 }
43
44 # vim: ft=sh