Linting
This commit is contained in:
@@ -16,6 +16,10 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
# On advice from http://redsymbol.net/articles/unofficial-bash-strict-mode/
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
# Prevent freak accidents involving the root directory
|
# Prevent freak accidents involving the root directory
|
||||||
if [ -z "$HOME" ]; then HOME=/home/"$(whoami)"; fi
|
if [ -z "$HOME" ]; then HOME=/home/"$(whoami)"; fi
|
||||||
|
|
||||||
@@ -32,6 +36,15 @@ readonly RED_COLOR='\033[1;31m'
|
|||||||
readonly YELLOW_COLOR='\033[1;33m'
|
readonly YELLOW_COLOR='\033[1;33m'
|
||||||
readonly RESET_COLOR='\033[0m'
|
readonly RESET_COLOR='\033[0m'
|
||||||
|
|
||||||
|
# Config variables
|
||||||
|
EXT=""
|
||||||
|
EDITOR=""
|
||||||
|
DATE_FMT=""
|
||||||
|
ENCRYPTION=""
|
||||||
|
PUBKEY=""
|
||||||
|
VCTL=""
|
||||||
|
|
||||||
|
|
||||||
# Signals
|
# Signals
|
||||||
NO_HEADER=""
|
NO_HEADER=""
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function decrypt(){
|
|||||||
# This function, given a file to decrypt, will attempt to decrypt the file
|
# This function, given a file to decrypt, will attempt to decrypt the file
|
||||||
# against the specified recipient's private key, and print the result to
|
# against the specified recipient's private key, and print the result to
|
||||||
# stdout.
|
# stdout.
|
||||||
read -s -p "Please enter GPG passphrase for id $PUBKEY: " PASSPHRASE
|
read -s -rp "Please enter GPG passphrase for id $PUBKEY: " PASSPHRASE
|
||||||
gpg\
|
gpg\
|
||||||
--passphrase "$PASSPHRASE"\
|
--passphrase "$PASSPHRASE"\
|
||||||
--decrypt "$FILE"\
|
--decrypt "$FILE"\
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ function create(){
|
|||||||
|
|
||||||
# If the note's notebook/section does not exist,
|
# If the note's notebook/section does not exist,
|
||||||
# create the appropriate folders.
|
# create the appropriate folders.
|
||||||
if [ ! -d "$(dirname $FILE)" ]; then
|
if [ ! -d "$(dirname "$FILE")" ]; then
|
||||||
mkdir -p "$(dirname $FILE)"
|
mkdir -p "$(dirname "$FILE")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Write the standard note header
|
# Write the standard note header
|
||||||
@@ -58,7 +58,7 @@ function delete(){
|
|||||||
|
|
||||||
if [ -e "$FILE" ]; then
|
if [ -e "$FILE" ]; then
|
||||||
printf "$RED_COLOR!!$RESET_COLOR %s%s" "Delete " "${NOTE%.*}"
|
printf "$RED_COLOR!!$RESET_COLOR %s%s" "Delete " "${NOTE%.*}"
|
||||||
read -p " (y/N) " YN
|
read -rp " (y/N) " YN
|
||||||
case "$YN" in
|
case "$YN" in
|
||||||
Y|y)
|
Y|y)
|
||||||
rm "$FILE"
|
rm "$FILE"
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ function verify_store {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
function verctl {
|
function verctl {
|
||||||
"$@"
|
ARGS=("$@")
|
||||||
if [ $2 == "init" ]; then
|
if [ "${ARGS[1]}" == "init" ]; then
|
||||||
"$VCTL" add .
|
"$VCTL" add .
|
||||||
"$VCTL" commit -m "Initial Commit"
|
"$VCTL" commit -m "Initial Commit"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ if [ "$ENCRYPTION" == "TRUE" ]; then
|
|||||||
# All is good. If any previously unencrypted notes exist, encrypt them.
|
# All is good. If any previously unencrypted notes exist, encrypt them.
|
||||||
# No harm in extra security.
|
# No harm in extra security.
|
||||||
else
|
else
|
||||||
find . -type f -name "*.$EXT" | grep -v "gpg" | while read TMP_NOTE; do
|
find . -type f -name "*.$EXT" | grep -v "gpg" | while read -r TMP_NOTE; do
|
||||||
NOTE="${TMP_NOTE%.$EXT}.gpg.$EXT"
|
NOTE="${TMP_NOTE%.$EXT}.gpg.$EXT"
|
||||||
encrypt
|
encrypt
|
||||||
if [ -r "$NOTE" ]; then
|
if [ -r "$NOTE" ]; then
|
||||||
@@ -65,10 +65,10 @@ else
|
|||||||
if [ ! -r "$NOTES_DIR"/.do_not_decrypt ]; then
|
if [ ! -r "$NOTES_DIR"/.do_not_decrypt ]; then
|
||||||
if [ -n "$(find "$NOTES_DIR" -type f -name "*.gpg.$EXT" > /dev/null)" ]; then
|
if [ -n "$(find "$NOTES_DIR" -type f -name "*.gpg.$EXT" > /dev/null)" ]; then
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Would you like to de-encrypt previously encrypted notes? " YN
|
read -rp "Would you like to de-encrypt previously encrypted notes? " YN
|
||||||
case $YN in
|
case $YN in
|
||||||
[Yy]* )
|
[Yy]* )
|
||||||
read -s -p "Please enter your passphrase: " PASSPHRASE
|
read -s -rp "Please enter your passphrase: " PASSPHRASE
|
||||||
cd "$NOTES_DIR"
|
cd "$NOTES_DIR"
|
||||||
find . -type f -name "*.gpg.$EXT" | while read -r NOTE; do
|
find . -type f -name "*.gpg.$EXT" | while read -r NOTE; do
|
||||||
gpg\
|
gpg\
|
||||||
@@ -101,9 +101,9 @@ fi
|
|||||||
#==============================================================================
|
#==============================================================================
|
||||||
# Stage 2: Argument Parsing
|
# Stage 2: Argument Parsing
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
if [ -z "$1" ]; then help; exit 20
|
if [ ! "$@" ]; then help; exit 20
|
||||||
else
|
else
|
||||||
ARGS=("${@}")
|
ARGS=("$@")
|
||||||
declare -i INDEX
|
declare -i INDEX
|
||||||
INDEX=0
|
INDEX=0
|
||||||
for ARG in "$@"; do
|
for ARG in "$@"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user