Files
vns/functions/edit.sns.sh
Jon-William Lewis 45717e33b5 Simple Note System v2.0a2
Changes:
Split script into several different files for easier editting
Added build.sh to compile Simple Note System from tree
Changed config file to config folder; $HOME/.sns now contains configuration and notes

Testing:
Script runs and produces help screen; no further testing done.
2015-03-18 12:52:00 -05:00

31 lines
743 B
Bash

#==========================================================================
# Subection: Edit
#==========================================================================
if [ "$EDIT" == "TRUE" ]; then
if [ -r "$NOTE" -o -r ${NOTE%.*} ]; then
if [ -z "$CREATE" ]; then
if [ "$ENCRYPTION" == "TRUE" ]; then
TMP_NAME=$ROOTDIR/tmp/$RANDOM
openssl enc -d -aes-256-cbc -in ${NOTE%.*} -pass pass:$ENC_KEY > $TMP_NAME
echo "" >> $TMP_NAME
echo "EDIT $(date)" >> $TMP_NAME
else
echo "" >> $NOTE
echo "EDIT $(date)" >> $NOTE
fi
fi
$EDITOR $NOTE
if [ "$ENCRYPTION" == "TRUE" ]; then
openssl enc -aes-256-cbc -salt -in $NOTE -out ${NOTE%.*} -pass pass:$ENC_KEY
rm $NOTE
fi
else
echo ""
echo "ERROR: Note cannot be opened for editting."
echo ""
fi
fi
fi