fixed print function and made appropriate changes to other parts of the program; changed version to alpha 8

This commit is contained in:
Jon-William Lewis
2016-01-25 21:20:20 -06:00
parent 2d8db83c3c
commit 25e5d399d1
6 changed files with 23 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
PROD_STR="Simple Note System" PROD_STR="Simple Note System"
VER_STR="v2.0a7" VER_STR="v2.0a8"
cat << EOF cat << EOF
#!/bin/bash #!/bin/bash

20
sns.sh
View File

@@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
#========================================================== #==========================================================
# Simple Note System, v2.0a6 # Simple Note System, v2.0a7
# Copyright 2014, Xenese Labs/Sicron-Perion XNF # Copyright 2014, Xenese Labs/Sicron-Perion XNF
#========================================================== #==========================================================
if [ -z "$HOME" ]; then HOME=/home/"$(whoami)"; fi if [ -z "$HOME" ]; then HOME=/home/"$(whoami)"; fi
PROD_STR="Simple Note System" PROD_STR="Simple Note System"
readonly VER_STR="v2.0a6" readonly VER_STR="v2.0a7"
readonly ROOT_DIR="$HOME"/.config/xenlabs/sns readonly ROOT_DIR="$HOME"/.config/xenlabs/sns
readonly BASE_DIR="$ROOT_DIR"/notes readonly BASE_DIR="$ROOT_DIR"/notes
readonly TMP_DIR="$ROOT_DIR"/tmp readonly TMP_DIR="$ROOT_DIR"/tmp
@@ -84,7 +84,7 @@ function decrypt(){
# This function, given a recipient, $PUBKEY; a file to decrypt, $TARGET; and an # This function, given a recipient, $PUBKEY; a file to decrypt, $TARGET; and an
# output file, "$NOTE", will decrpyt $TARGET to $NOTE against $PUBKEY's private # output file, "$NOTE", will decrpyt $TARGET to $NOTE against $PUBKEY's private
# GPG key. # GPG key.
echo "$NOTE"; pause
gpg -d "$NOTE" gpg -d "$NOTE"
} }
function create(){ function create(){
@@ -132,7 +132,8 @@ fi
if [ "$ENCRYPTION" == "TRUE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then
cp "$NOTE" "$NOTE".bk cp "$NOTE" "$NOTE".bk
if [ ! -d "$ROOT_DIR"/tmp ]; then mkdir "$ROOT_DIR"/tmp; fi if [ ! -d "$ROOT_DIR"/tmp ]; then mkdir "$ROOT_DIR"/tmp; fi
decrypt > "$TMP_DIR/$RANDOM" TARGET="$TMP_DIR/$SESSION_ID"
decrypt > "$TARGET"
else TARGET="$NOTE"; fi else TARGET="$NOTE"; fi
@@ -162,8 +163,8 @@ function print(){
function list(){ function list(){
if [ -d "$BASE_DIR"/"$NOTEBOOK" ]; then if [ -d "$BASE_DIR"/"$NOTEBOOK" ]; then
printf "+%s\n" "$NOTEBOOK" printf "+%s\n" "$NOTEBOOK"
find "$BASE_DIR"/"$NOTEBOOK" -type f | while read NOTE; do find "$BASE_DIR"/"$NOTEBOOK" -type f | while read -r NOTE; do
printf " -%s\n" "$(basename $NOTE | cut -d . -f 1)" printf " -%s\n" "$(basename \"$NOTE\" | cut -d . -f 1 )"
done done
fi fi
} }
@@ -288,9 +289,12 @@ fi
SESSION_ID="$RANDOM" SESSION_ID="$RANDOM"
NOTE_DIR="$BASE_DIR"/"$NOTEBOOK"/"$SECTION"/ NOTE_DIR="$BASE_DIR"/"$NOTEBOOK"/"$SECTION"/
NOTE="$NOTE_DIR""$NAME"."$EXT"
if [ "$ENCRYPTION" == "TRUE" ]; then NOTE="$NOTE".gpg; fi
if [ "$ENCRYPTION" == "TRUE" ]; then readonly NOTE="$NOTE_DIR""$NAME"."$EXT".gpg
else readonly NOTE="$NOTE_DIR""$NAME"."$EXT"
fi
if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi
if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi
if [ "$CREATE" == "TRUE" ]; then create; fi if [ "$CREATE" == "TRUE" ]; then create; fi

View File

@@ -7,7 +7,8 @@ fi
if [ "$ENCRYPTION" == "TRUE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then
cp "$NOTE" "$NOTE".bk cp "$NOTE" "$NOTE".bk
if [ ! -d "$ROOT_DIR"/tmp ]; then mkdir "$ROOT_DIR"/tmp; fi if [ ! -d "$ROOT_DIR"/tmp ]; then mkdir "$ROOT_DIR"/tmp; fi
decrypt > "$TMP_DIR/$RANDOM" TARGET="$TMP_DIR/$SESSION_ID"
decrypt > "$TARGET"
else TARGET="$NOTE"; fi else TARGET="$NOTE"; fi

View File

@@ -11,6 +11,6 @@ function decrypt(){
# This function, given a recipient, $PUBKEY; a file to decrypt, $TARGET; and an # This function, given a recipient, $PUBKEY; a file to decrypt, $TARGET; and an
# output file, "$NOTE", will decrpyt $TARGET to $NOTE against $PUBKEY's private # output file, "$NOTE", will decrpyt $TARGET to $NOTE against $PUBKEY's private
# GPG key. # GPG key.
echo "$NOTE"; pause
gpg -d "$NOTE" gpg -d "$NOTE"
} }

View File

@@ -1,8 +1,8 @@
function list(){ function list(){
if [ -d "$BASE_DIR"/"$NOTEBOOK" ]; then if [ -d "$BASE_DIR"/"$NOTEBOOK" ]; then
printf "+%s\n" "$NOTEBOOK" printf "+%s\n" "$NOTEBOOK"
find "$BASE_DIR"/"$NOTEBOOK" -type f | while read NOTE; do find "$BASE_DIR"/"$NOTEBOOK" -type f | while read -r NOTE; do
printf " -%s\n" "$(basename $NOTE | cut -d . -f 1)" printf " -%s\n" "$(basename \"$NOTE\" | cut -d . -f 1 )"
done done
fi fi
} }

View File

@@ -23,9 +23,12 @@ fi
SESSION_ID="$RANDOM" SESSION_ID="$RANDOM"
NOTE_DIR="$BASE_DIR"/"$NOTEBOOK"/"$SECTION"/ NOTE_DIR="$BASE_DIR"/"$NOTEBOOK"/"$SECTION"/
NOTE="$NOTE_DIR""$NAME"."$EXT"
if [ "$ENCRYPTION" == "TRUE" ]; then NOTE="$NOTE".gpg; fi
if [ "$ENCRYPTION" == "TRUE" ]; then readonly NOTE="$NOTE_DIR""$NAME"."$EXT".gpg
else readonly NOTE="$NOTE_DIR""$NAME"."$EXT"
fi
if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi if [ "$PRINT" == "TRUE" ]; then print; exit 0; fi
if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi if [ "$DELETE" == "TRUE" ]; then delete; exit 0; fi
if [ "$CREATE" == "TRUE" ]; then create; fi if [ "$CREATE" == "TRUE" ]; then create; fi