update repository
[cmdllinux.git] / bash_n_examples / bash / fd / err_log_debug_info3.sh
blob5264257ed986d2993f6d6b1b36e7feb07a22badd
1 #!/bin/bash
3 log() {
4 echo $* >&3
6 info() {
7 echo $* >&4
9 err() {
10 echo $* >&2
12 debug() {
13 echo $* >&5
16 VERBOSE=1
18 while [[ $# -gt 0 ]]; do
19 ARG=$1
20 shift
21 case $ARG in
22 "-vv")
23 VERBOSE=3
25 "-v")
26 VERBOSE=2
28 "-q")
29 VERBOSE=0
31 # More flags
33 echo -n
34 # Linear args
36 esac
37 done
39 for i in 1 2 3; do
40 fd=$(expr 2 + $i)
41 if [[ $VERBOSE -ge $i ]]; then
42 eval "exec $fd>&1"
43 else
44 eval "exec $fd> /dev/null"
46 done
48 err "This will _always_ show up."
49 log "This is normally displayed, but can be prevented with -q"
50 info "This will only show up if -v is passed"
51 debug "This will show up for -vv"