Bladeren bron

Clean up and consolidate field printing code in [ts]find

Alois Mahdal 6 jaren geleden
bovenliggende
commit
dedc200a64
2 gewijzigde bestanden met toevoegingen van 16 en 15 verwijderingen
  1. 9
    11
      src/libexec/jattool-sfind
  2. 7
    4
      src/libexec/jattool-tfind

+ 9
- 11
src/libexec/jattool-sfind Bestand weergeven

@@ -72,18 +72,16 @@ discover() {
72 72
             SuiteDomain=$(sprop domain)
73 73
             SuiteNs=$(sprop ns)
74 74
             SuiteSutPname=$(sprop sut_pname)
75
+            SuiteVersion=$(sprop version)
76
+            SuiteId=$(
77
+                echo -n "jats://$SuiteDomain/$SuiteNs"
78
+                test -n "$SuiteSutPname" && echo -n "/$SuiteSutPname"
79
+                echo //
80
+            )
75 81
             case $Fmt in
76
-                id)
77
-                    echo -n "jats://$SuiteDomain/$SuiteNs"
78
-                    test -n "$SuiteSutPname" && echo -n "/$SuiteSutPname"
79
-                    echo //
80
-                    ;;
81
-                path)
82
-                    echo "$SuiteDir"
83
-                    ;;
84
-                version)
85
-                    sprop version
86
-                    ;;
82
+                id)       echo "$SuiteId"      ;;
83
+                path)     echo "$SuiteDir"     ;;
84
+                version)  echo "$SuiteVersion" ;;
87 85
             esac
88 86
         done
89 87
 }

+ 7
- 4
src/libexec/jattool-tfind Bestand weergeven

@@ -29,11 +29,14 @@ discover() {
29 29
             t_apath=$(dirname "$(readlink -f "$t_cand")")
30 30
             t_rpath=${t_apath#$s_dir/}
31 31
             s_id=$(jattool sfind -f id "$s_dir")
32
-            debug -v s_dir s_id t_apath t_rpath
32
+            s_ver=$(jattool sfind -f version "$s_dir")
33
+            t_id=$s_id$t_rpath
34
+            t_path=$s_dir/$t_rpath
35
+            debug -v s_dir s_id t_apath t_rpath t_id t_path
33 36
             case $Fmt in
34
-                path) echo "$s_dir/$t_rpath" ;;
35
-                id) echo "$s_id$t_rpath"   ;;
36
-                version) jattool sfind -f version "$s_dir" ;;
37
+                path)    echo "$t_path" ;;
38
+                id)      echo "$t_id"   ;;
39
+                version) echo "$s_ver"  ;;
37 40
             esac
38 41
         done
39 42
 }