Browse Source

Have saturnin-conf exit with useful statuses

Alois Mahdal 7 years ago
parent
commit
a9c5485148
1 changed files with 9 additions and 4 deletions
  1. 9
    4
      src/shellfu/saturnin.sh

+ 9
- 4
src/shellfu/saturnin.sh View File

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