Skip to content

Commit 3f40aac

Browse files
author
Konrad Lother
committed
small fixes
1 parent f3e6531 commit 3f40aac

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

file.bash

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,29 @@ cmd_edit() {
7070
print_usage
7171
fi
7272

73+
if [[ ${path: -4} != ".b64" ]]; then
74+
path="${path}.b64"
75+
fi
76+
77+
local passfile="$PREFIX/$path.gpg"
78+
7379
if [[ -z $EDITOR ]]; then
7480
echo "\$EDITOR not set, don't know how to open file."
7581
exit 1
7682
else
7783
local tmpfile=$(mktemp)
84+
local newfile=0
7885
chmod 0600 $tmpfile
79-
80-
cmd_retrieve $path > $tmpfile
81-
if [[ $? -ne 0 ]]; then
82-
rm $tmpfile
83-
exit 1
86+
87+
if [[ -f $passfile ]]; then
88+
cmd_retrieve $path > $tmpfile
89+
if [[ $? -ne 0 ]]; then
90+
rm $tmpfile
91+
exit 1
92+
fi
93+
else
94+
echo "File does not exist, creating new file..."
95+
sleep 3
8496
fi
8597

8698
$EDITOR $tmpfile

0 commit comments

Comments
 (0)