Browse Source

Add error handling for when vault does not exist

Forest Belton 11 months ago
parent
commit
3d7019beeb
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      get

+ 8
- 1
get View File

@@ -1,9 +1,16 @@
1 1
 #!/bin/bash
2 2
 set -euo pipefail
3 3
 
4
+VAULT=vault
5
+
4 6
 function main {
7
+    if [ ! -f "$VAULT" ]; then
8
+        echo 'error: no vault exists'
9
+        exit 1
10
+    fi
11
+
5 12
     KEY="$1"
6
-    VALUE=$(gpg --decrypt vault | jq ".$KEY")
13
+    VALUE=$(gpg --decrypt "$VAULT" | jq ".$KEY")
7 14
 
8 15
     if [ "$VALUE" = "null" ]; then
9 16
         echo 'error: no key exists'

Loading…
Cancel
Save