Przeglądaj źródła

Add has_files directory test

Alois Mahdal 9 lat temu
rodzic
commit
b2b8704a67
2 zmienionych plików z 15 dodań i 0 usunięć
  1. 14
    0
      include/recon.sh
  2. 1
    0
      test/data/ffoo_api/functions.oracle.stdout

+ 14
- 0
include/recon.sh Wyświetl plik

@@ -38,6 +38,20 @@ cat_uri() {
38 38
 }
39 39
 
40 40
 
41
+has_files() {
42
+    #
43
+    # Directory exists and has at least one file
44
+    #
45
+    test -d "$1" || return 1
46
+    test -e "$1"/* &>/dev/null
47
+    case $? in
48
+        0) return 0 ;;
49
+        1) return 1 ;;
50
+        *) return 0 ;;
51
+    esac
52
+}
53
+
54
+
41 55
 pids_matching() {
42 56
     #
43 57
     # Print list of PIDs where command matches regex(es)

+ 1
- 0
test/data/ffoo_api/functions.oracle.stdout Wyświetl plik

@@ -63,6 +63,7 @@ recon.age_of_leaf
63 63
 recon.age_of_tree
64 64
 recon.cat_uri
65 65
 recon.filter_hosts
66
+recon.has_files
66 67
 recon.listening_on
67 68
 recon.pids_matching
68 69
 recon.reachable_by_ping