Fix input bug
A newline input doesn't result in an error anymore.
This commit is contained in:
parent
79e9e6ed0d
commit
bfc7fd6de6
10 changed files with 186 additions and 113 deletions
20
uninstall.sh
20
uninstall.sh
|
@ -13,7 +13,8 @@ echo "2.Disable shellnotes and all its commands, but keep the files in your syst
|
|||
echo "3.Enable shellnotes."
|
||||
echo ""
|
||||
echo -n "[1,2,3]: " && read option
|
||||
if [ $option = "1" ]; then
|
||||
|
||||
case $option in 1 )
|
||||
if [ -e ~/.shellnotes/.shellnotes.sh ]; then
|
||||
echo -n "Are you sure you want to delete Shellnotes?[Y/N]: " && read delete
|
||||
case $delete in y|Y|YES|Yes|yes )
|
||||
|
@ -82,9 +83,9 @@ if [ $option = "1" ]; then
|
|||
./uninfailed
|
||||
cd $DIR
|
||||
fi
|
||||
esac
|
||||
|
||||
|
||||
elif [ $option = "2" ]; then
|
||||
case $option in 2 )
|
||||
if grep 'return' <~/.shellnotes/.shellnotes.sh >/dev/null; then
|
||||
echo "Shellnotes is already disabled."
|
||||
cd ~/.shellnotes/util/exec
|
||||
|
@ -94,7 +95,9 @@ elif [ $option = "2" ]; then
|
|||
sed -i '2 i\return 0 #Shellnotes is disabled by the user. Do not change this line.' ~/.shellnotes/.shellnotes.sh
|
||||
echo "Shellnotes is now disabled. To enable, run this script again and choose option (3)."
|
||||
fi
|
||||
elif [ $option = "3" ]; then
|
||||
esac
|
||||
|
||||
case $option in 3 )
|
||||
if grep 'return' <~/.shellnotes/.shellnotes.sh >/dev/null; then
|
||||
sed -i '2d' ~/.shellnotes/.shellnotes.sh
|
||||
echo "Shellnotes is now enabled. Please restart your terminal."
|
||||
|
@ -104,9 +107,10 @@ elif [ $option = "3" ]; then
|
|||
./enfailed
|
||||
cd $DIR
|
||||
fi
|
||||
else
|
||||
echo "This is not an option."
|
||||
fi
|
||||
|
||||
esac
|
||||
|
||||
|
||||
case $option in
|
||||
(*[a-zA-Z]* | "" )
|
||||
echo "Invalid input."
|
||||
esac
|
||||
|
|
|
@ -11,16 +11,24 @@ function delnote() {
|
|||
else
|
||||
delete=$1
|
||||
fi
|
||||
|
||||
if [ -z $delete ]; then
|
||||
echo "Invalid input."
|
||||
return 0
|
||||
|
||||
else
|
||||
if [[ $1 == "-all" ]]; then
|
||||
cd $DEFAULT_PATH
|
||||
rm -f *
|
||||
clear
|
||||
cd $DIR
|
||||
str="All files deleted from $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
cd $DEFAULT_PATH
|
||||
rm -f *
|
||||
clear
|
||||
cd $DIR
|
||||
str="All files deleted from $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
|
||||
else
|
||||
cd $DEFAULT_PATH
|
||||
|
||||
if [ -e $delete ]; then
|
||||
rm $delete
|
||||
clear
|
||||
|
@ -29,8 +37,9 @@ function delnote() {
|
|||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
else
|
||||
echo "No such file."
|
||||
echo "Invalid argument or parameter given."
|
||||
cd $DIR
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
|
@ -11,6 +11,12 @@ function findmisplacednote() {
|
|||
else
|
||||
notename=$1
|
||||
fi
|
||||
echo "Possible locations: "
|
||||
find ~/ -iname $notename -print 2>/dev/null
|
||||
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
return 0
|
||||
else
|
||||
echo "Possible locations: "
|
||||
find ~/ -iname $notename -print 2>/dev/null
|
||||
fi
|
||||
}
|
|
@ -11,14 +11,20 @@ function findnote() {
|
|||
else
|
||||
notename=$1
|
||||
fi
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
echo "File was found in your Notes folder."
|
||||
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
return 0
|
||||
else
|
||||
echo "File was not found in your Notes folder, must be misplaced or renamed."
|
||||
echo "Try 'findmisplacednote' to find the original file."
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
echo "File was found in your Notes folder."
|
||||
else
|
||||
echo "File was not found in your Notes folder, must be misplaced or renamed."
|
||||
echo "Try 'findmisplacednote' to find the original file."
|
||||
|
||||
fi
|
||||
fi
|
||||
cd $DIR
|
||||
|
||||
cd $DIR
|
||||
}
|
||||
|
|
33
util/l/l.sh
33
util/l/l.sh
|
@ -16,22 +16,29 @@ case $1 in -l|--logs )
|
|||
echo "4. update errors"
|
||||
echo "5. uninstallation errors"
|
||||
echo "6. set-defaults errors"
|
||||
echo
|
||||
echo "For more info about which one to choose, read /docs/system/loggingsystem.txt"
|
||||
echo
|
||||
echo -n "[1,2,3,4,5]: " && read input
|
||||
if [ $input = 1 ]; then
|
||||
less ~/.shellnotes/logs/disfailed.txt
|
||||
elif [ $input = 2 ]; then
|
||||
less ~/.shellnotes/logs/enfailed.txt
|
||||
elif [ $input = 3 ]; then
|
||||
less ~/.shellnotes/logs/ifailed.txt
|
||||
elif [ $input = 4 ]; then
|
||||
less ~/.shellnotes/logs/ufailed.txt
|
||||
elif [ $input = 5 ]; then
|
||||
less ~/.shellnotes/logs/uninfailed.txt
|
||||
elif [ $input = 6 ]; then
|
||||
less ~/.shellnotes/logs/sdfailed.txt
|
||||
else
|
||||
if [ -z $input ]; then
|
||||
echo "Invalid input."
|
||||
return 0
|
||||
else
|
||||
|
||||
if [ $input = 1 ]; then
|
||||
less ~/.shellnotes/logs/disfailed.txt
|
||||
elif [ $input = 2 ]; then
|
||||
less ~/.shellnotes/logs/enfailed.txt
|
||||
elif [ $input = 3 ]; then
|
||||
less ~/.shellnotes/logs/ifailed.txt
|
||||
elif [ $input = 4 ]; then
|
||||
less ~/.shellnotes/logs/ufailed.txt
|
||||
elif [ $input = 5 ]; then
|
||||
less ~/.shellnotes/logs/uninfailed.txt
|
||||
elif [ $input = 6 ]; then
|
||||
less ~/.shellnotes/logs/sdfailed.txt
|
||||
else
|
||||
echo "Invalid input."
|
||||
fi
|
||||
fi
|
||||
esac
|
|
@ -6,11 +6,13 @@ in /docs/github/ for its full text.
|
|||
info
|
||||
|
||||
function newnote() {
|
||||
cd $DEFAULT_PATH
|
||||
$NOTES_EDITOR
|
||||
clear
|
||||
cd $DIR
|
||||
str="Note created in $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
|
||||
cd $DEFAULT_PATH
|
||||
$NOTES_EDITOR
|
||||
clear
|
||||
cd $DIR
|
||||
str="Note created in $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
|
||||
}
|
|
@ -11,12 +11,20 @@ function noteinfo() {
|
|||
else
|
||||
notename=$1
|
||||
fi
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
wc $notename
|
||||
echo "(lines/words/chars/name)"
|
||||
else
|
||||
echo "That note doesn't exist."
|
||||
fi
|
||||
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
return 0
|
||||
else
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
wc $notename
|
||||
echo "(lines/words/chars/name)"
|
||||
else
|
||||
echo "That note doesn't exist."
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $DIR
|
||||
|
||||
}
|
|
@ -6,37 +6,47 @@ in /docs/github/ for its full text.
|
|||
info
|
||||
|
||||
function quicknote() {
|
||||
if [ $# -eq 0 ]; then
|
||||
echo -n "Enter note name: " && read notename
|
||||
else
|
||||
notename=$1
|
||||
fi
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
clear
|
||||
echo "This note already exists."
|
||||
cd ..
|
||||
echo -n "Do you want to read it?[Y/N]: " && read readquicknote
|
||||
|
||||
else
|
||||
touch $notename
|
||||
$QUICK_NOTES_EDITOR $notename
|
||||
cd $DIR
|
||||
clear
|
||||
str="Note created in $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
|
||||
fi
|
||||
|
||||
case $readquicknote in y|Y|YES|Yes|yes )
|
||||
clear
|
||||
cd $DEFAULT_PATH
|
||||
if [[ -e $notename ]]; then
|
||||
cat $notename
|
||||
if [ $# -eq 0 ]; then
|
||||
echo -n "Enter note name: " && read notename
|
||||
else
|
||||
echo "This note is blank."
|
||||
notename=$1
|
||||
fi
|
||||
esac
|
||||
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
return 0
|
||||
|
||||
else
|
||||
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
clear
|
||||
echo "This note already exists."
|
||||
cd ..
|
||||
echo -n "Do you want to read it?[Y/N]: " && read readquicknote
|
||||
|
||||
else
|
||||
touch $notename
|
||||
$QUICK_NOTES_EDITOR $notename
|
||||
cd $DIR
|
||||
clear
|
||||
str="Note created in $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
|
||||
fi
|
||||
|
||||
case $readquicknote in y|Y|YES|Yes|yes )
|
||||
clear
|
||||
cd $DEFAULT_PATH
|
||||
if [[ -e $notename ]]; then
|
||||
cat $notename
|
||||
else
|
||||
echo "This note is blank."
|
||||
fi
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
cd $DIR
|
||||
}
|
|
@ -12,23 +12,29 @@ function readnote() {
|
|||
notename=$1
|
||||
fi
|
||||
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
chmod 0444 $notename
|
||||
$NOTES_EDITOR $notename
|
||||
chmod +rw $notename
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
return 0
|
||||
|
||||
else
|
||||
|
||||
cd $DEFAULT_PATH
|
||||
if [ -e $notename ]; then
|
||||
chmod 0444 $notename
|
||||
$NOTES_EDITOR $notename
|
||||
chmod +rw $notename
|
||||
|
||||
else
|
||||
clear
|
||||
echo "No such note."
|
||||
echo -n "Do you want to create one?[Y/N]: " && read create;
|
||||
fi
|
||||
|
||||
case $create in y|Y|YES|Yes|yes )
|
||||
$NOTES_EDITOR
|
||||
esac
|
||||
|
||||
clear
|
||||
echo "No such note."
|
||||
echo -n "Do you want to create one?[Y/N]: " && read create;
|
||||
cd $DIR
|
||||
fi
|
||||
|
||||
case $create in y|Y|YES|Yes|yes )
|
||||
$NOTES_EDITOR
|
||||
esac
|
||||
|
||||
clear
|
||||
cd $DIR
|
||||
|
||||
}
|
|
@ -15,20 +15,35 @@ function renamenote() {
|
|||
newnotename=$2
|
||||
fi
|
||||
|
||||
if [ -e $notename ]; then
|
||||
if [ -e $newnotename ]; then
|
||||
echo "There is another note named '$newnotename' in your Notes folder."
|
||||
else
|
||||
mv $notename $newnotename
|
||||
clear
|
||||
str="Note renamed from $notename to $newnotename in $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
fi
|
||||
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
cd $DIR
|
||||
return 0
|
||||
|
||||
elif [ -z $newnotename ]; then
|
||||
echo "Invalid input."
|
||||
cd $DIR
|
||||
return 0
|
||||
|
||||
else
|
||||
echo "This note does not exist."
|
||||
fi
|
||||
|
||||
if [ -e $notename ]; then
|
||||
if [ -e $newnotename ]; then
|
||||
echo "There is another note named '$newnotename' in your Notes folder."
|
||||
else
|
||||
mv $notename $newnotename
|
||||
clear
|
||||
str="Note renamed from $notename to $newnotename in $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "This note does not exist."
|
||||
fi
|
||||
|
||||
cd $DIR
|
||||
|
||||
fi
|
||||
}
|
Loading…
Reference in a new issue