Further sanitization of variables; checks out with shellcheck.net now

This commit is contained in:
Jon-William Lewis
2015-06-10 08:35:16 -05:00
parent 9334f3ba45
commit 121abb1df7
10 changed files with 60 additions and 64 deletions

View File

@@ -25,7 +25,7 @@
#}
function create(){
if [ -e "$NOTE" -o -e ${NOTE%.*} ]; then
if [ -e "$NOTE" -o -e "${NOTE%.*}" ]; then
printf "\nERROR: Note already exists\nHint: use -e to edit the note.\n"
exit
else
@@ -33,12 +33,12 @@ function create(){
fi
if [ -z "$ENCRYPTION" ]; then
echo "TITLE: $NAME" > $NOTE
echo "DATE: $(date)" >> $NOTE
echo "TITLE: $NAME" > "$NOTE"
echo "DATE: $(date)" >> "$NOTE"
elif [ "$ENCRYPTION" == "TRUE" ]; then
touch "$NOTE"
echo "$(p_header)" | openssl enc -aes-256-cbc -salt -out "$NOTE"\
-pass pass:$ENC_KEY
p_header | openssl enc -aes-256-cbc -salt -out "$NOTE"\
-pass pass:"$ENC_KEY"
fi
echo "$NOTE"
}

View File

@@ -1,10 +1,10 @@
function delete(){
if [ "$DELETE" == "TRUE" ]; then
if [ -e $NOTE -o -e ${NOTE%.*} ]; then
if [ -e "$NOTE" -o -e "${NOTE%.*}" ]; then
if [ "$ENCRYPTION" == "TRUE" ]; then
rm ${NOTE%.*}
rm "${NOTE%.*}"
else
rm $NOTE
rm "$NOTE"
fi
echo ""
echo "Deleted note: $NOTEBOOK/$SECTION$NAME."

View File

@@ -8,9 +8,7 @@ if [ "$ENCRYPTION" == "TRUE" ]; then decrypt
else TARGET="$NOTE"; fi
if [ -z "$CREATE" ]; then printf "\nEDIT $(date)" >> "$TARGET"; fi
if [ -z "$CREATE" ]; then printf "\nEDIT %s" "$(date)" >> "$TARGET"; fi
"$EDITOR" "$TARGET"

View File

@@ -1,22 +1,20 @@
function list(){
if [ -d "$BASEDIR"/"$NOTEBOOK" ]; then
echo ""
printf "Notes in $(basename $NOTEBOOK):"
echo ""
printf "\nNotes in %s:\n" "$(basename "$NOTEBOOK")"
NOTES=( $(find $BASEDIR/$NOTEBOOK -name "*.$EXT" -print0 | sed s:$BASEDIR/$NOTEBOOK/:" ":g | sed -e s:".$EXT"::g | tr "/" " ") )
NOTES=( $(find "$BASEDIR"/"$NOTEBOOK" -name "*.$EXT" -print0 | sed s:"$BASEDIR"/"$NOTEBOOK"/: " " :g | sed -e s:".$EXT"::g | tr "/" " ") )
let i=0
for NOTE in ${NOTES[@]}; do
if [ -d $BASEDIR/$NOTEBOOK/$NOTE ]; then
for NOTE in "${NOTES[@]}"; do
if [ -d "$BASEDIR"/"$NOTEBOOK"/"$NOTE" ]; then
if [ "$LAST_SECTION" != "$NOTE" ]; then
printf " Section: $NOTE\n"
printf " Section: %s\n" "$NOTE"
fi
LAST_SECTION=$NOTE
LAST_SECTION="$NOTE"
else
#if [ $(($i % 1)) -eq 0 ]; then
# printf "\n "
#fi
printf " $NOTE\n"
printf " %s\n" "$NOTE"
fi
let i++
done

View File

@@ -1,3 +1,3 @@
function p_header(){
printf "TITLE: $NAME\nDATE: $(date)\n"
printf "TITLE: %s\nDATE: %s\n" "$NAME" "$(date)"
}

View File

@@ -1,12 +1,12 @@
function print(){
if [ "$PRINT" == "TRUE" ]; then
if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then
if [ -r "$NOTE" -o -r "${NOTE%.*}" ]; then
if [ -z "$CREATE" ]; then
if [ "$ENCRYPTION" == "TRUE" ]; then
openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY
openssl enc -d -aes-256-cbc -in "${NOTE%.*}" -pass pass:"$ENC_KEY"
else
cat $NOTE
echo "" >> $NOTE
cat "$NOTE"
echo "" >> "$NOTE"
fi
else
echo ""

View File

@@ -1,5 +1,5 @@
function w_conf {
if [ ! -r "$ROOTDIR" ]; then mkdir -p $ROOTDIR; fi
if [ ! -r "$ROOTDIR" ]; then mkdir -p "$ROOTDIR"; fi
cat > "$CONFIGURATION" << EOF
#==========================================================
# Simple Note System Config, v2.0a5