浏览代码

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

Alois Mahdal 11 年前
父节点
当前提交
c81b21781c
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15
    2
      include/core.sh

+ 15
- 2
include/core.sh 查看文件

@@ -123,17 +123,30 @@ think() {
123 123
     #
124 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 136
 warn() {
130 137
     #
131 138
     # Warn them
132 139
     #
140
+    # Use "-l" to split every parameter to separate line, (useful
141
+    # or longer warnings)
142
+    #
133 143
     # Resist  temptation to prefix "warning" or similar BS here.
134 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 152
 append_if_missing() {