Browse Source

Return informative exit status from jat__sfinish()

Alois Mahdal 6 years ago
parent
commit
ba77411e50
1 changed files with 17 additions and 0 deletions
  1. 17
    0
      src/jat.sh.skel

+ 17
- 0
src/jat.sh.skel View File

494
     # leftover session and whole log will be merged.
494
     # leftover session and whole log will be merged.
495
     #
495
     #
496
     local fileas    # session id for filing in 'finished' folder
496
     local fileas    # session id for filing in 'finished' folder
497
+    local es        # final exit status
497
     test -d "$JAT__DIR/session" || {
498
     test -d "$JAT__DIR/session" || {
498
         __jat__show_error "no active session: no $JAT__DIR/session"
499
         __jat__show_error "no active session: no $JAT__DIR/session"
499
         return 2
500
         return 2
500
     }
501
     }
502
+    es=$(__jat__final_es)
501
     __jat__show_sfinish
503
     __jat__show_sfinish
502
     __jat__log_event SINFO "finishing session"
504
     __jat__log_event SINFO "finishing session"
503
     __jat__writelog <<<"finalized: true"
505
     __jat__writelog <<<"finalized: true"
507
     mv "$JAT__DIR/session" "$JAT__DIR/finished/$fileas"
509
     mv "$JAT__DIR/session" "$JAT__DIR/finished/$fileas"
508
     rm -f "$JAT__DIR/last"
510
     rm -f "$JAT__DIR/last"
509
     ln -s "finished/$fileas" "$JAT__DIR/last"
511
     ln -s "finished/$fileas" "$JAT__DIR/last"
512
+    return "$es"
510
 }
513
 }
511
 
514
 
512
 jat__log_error() {
515
 jat__log_error() {
823
     return 1
826
     return 1
824
 }
827
 }
825
 
828
 
829
+__jat__final_es() {
830
+    #
831
+    # Print final exit status
832
+    #
833
+    # Roughly follows TFKit's semantic; unoffical link:
834
+    #
835
+    #     https://github.com/AloisMahdal/shellfu/tree/master/utils/tfkit/doc
836
+    #
837
+    test "$(jat__stat serrc)"  -gt 0 && echo 4 && return
838
+    test "$(jat__stat swarc)"  -gt 0 && echo 3 && return
839
+    test "$(jat__stat sfailc)" -gt 0 && echo 1 && return
840
+    echo 0
841
+}
842
+
826
 __jat__log_event() {
843
 __jat__log_event() {
827
     #
844
     #
828
     # Pass YAML log event to __jat__writelog()
845
     # Pass YAML log event to __jat__writelog()