Browse Source

Add -l option to warn() and think()

Alois Mahdal 11 years ago
parent
commit
c81b21781c
1 changed files with 15 additions and 2 deletions
  1. 15
    2
      include/core.sh

+ 15
- 2
include/core.sh View File

123
     #
123
     #
124
     # If verose is on, think loud.
124
     # If verose is on, think loud.
125
     #
125
     #
126
-    $FFOOD_VERBOSE && echo "$@"
126
+    # Use "-l" to split every parameter to separate line, (useful
127
+    # or longer warnings)
128
+    #
129
+    $FFOOD_VERBOSE || return 0
130
+    case "$1" in
131
+        -l) shift; local l; for l in "$@"; do echo "$l" >&2; done   ;;
132
+        *)  echo "$@" >&2;                                          ;;
133
+    esac
127
 }
134
 }
128
 
135
 
129
 warn() {
136
 warn() {
130
     #
137
     #
131
     # Warn them
138
     # Warn them
132
     #
139
     #
140
+    # Use "-l" to split every parameter to separate line, (useful
141
+    # or longer warnings)
142
+    #
133
     # Resist  temptation to prefix "warning" or similar BS here.
143
     # Resist  temptation to prefix "warning" or similar BS here.
134
     # STDERR is *made* for warnings.
144
     # STDERR is *made* for warnings.
135
     #
145
     #
136
-    echo "$*" >&2
146
+    case "$1" in
147
+        -l) shift; local l; for l in "$@"; do echo "$l" >&2; done   ;;
148
+        *)  echo "$@" >&2;                                          ;;
149
+    esac
137
 }
150
 }
138
 
151
 
139
 append_if_missing() {
152
 append_if_missing() {