ソースを参照

Have saturnin-conf exit with useful statuses

Alois Mahdal 8 年 前
コミット
a9c5485148
共有1 個のファイルを変更した9 個の追加4 個の削除を含む
  1. 9
    4
      src/shellfu/saturnin.sh

+ 9
- 4
src/shellfu/saturnin.sh ファイルの表示

@@ -113,6 +113,7 @@ saturnin__conf() {
113 113
     debug -v files
114 114
     #shellcheck disable=SC2086
115 115
     _saturnin__conf__load "${files[@]}" | inigrep $ig_limit $ig_mode $ig_query
116
+    return "${PIPESTATUS[0]}"
116 117
 }
117 118
 
118 119
 saturnin__get() {
@@ -301,9 +302,11 @@ _saturnin__conf__merge() {
301 302
     # Take paths and applying merge strategy, load file(s)
302 303
     #
303 304
     local path
305
+    local found=false
304 306
     while read -r path;
305 307
     do
306 308
         test -f "$path" || continue
309
+        found=true
307 310
         case $Strategy in
308 311
             first)
309 312
                 debug "winner: $path"
@@ -316,6 +319,7 @@ _saturnin__conf__merge() {
316 319
                 ;;
317 320
         esac
318 321
     done
322
+    $found
319 323
 }
320 324
 
321 325
 _saturnin__conf__load() {
@@ -331,12 +335,13 @@ _saturnin__conf__load() {
331 335
     # with 'first' strategy, first existing file is printed, with
332 336
     # 'join' strategy. all existing files are printed.
333 337
     #
334
-    local arg trydir trypath
338
+    local arg trydir trypath es
339
+    es=0
335 340
     for arg in "$@";
336 341
     do
337 342
         case $arg in
338 343
             -|*/*)      # stdin, or path (with slash)
339
-                cat "$arg"
344
+                cat "$arg" || es=3
340 345
             ;;
341 346
         *)              # name given, find all its incarnations
342 347
             debug -v SATURNIN_CONF_PATH
@@ -348,11 +353,11 @@ _saturnin__conf__load() {
348 353
                     trypath="$trydir/$arg"
349 354
                     echos "$trypath"
350 355
                 done \
351
-              |  _saturnin__conf__merge
356
+              |  _saturnin__conf__merge; es=$?
352 357
             ;;
353 358
         esac
354 359
     done
355
-    true
360
+    return $es
356 361
 }
357 362
 
358 363
 _saturnin__conf_usage() {