Fix input bug

A newline input doesn't result in an error anymore.
This commit is contained in:
dmarakom6 2021-04-25 13:23:38 +03:00
parent 79e9e6ed0d
commit bfc7fd6de6
10 changed files with 186 additions and 113 deletions

View file

@ -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

View file

@ -11,6 +11,12 @@ 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 *
@ -19,8 +25,10 @@ function delnote() {
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
}

View file

@ -11,6 +11,12 @@ function findmisplacednote() {
else
notename=$1
fi
if [ -z $notename ]; then
echo "Invalid input."
return 0
else
echo "Possible locations: "
find ~/ -iname $notename -print 2>/dev/null
fi
}

View file

@ -11,6 +11,11 @@ function findnote() {
else
notename=$1
fi
if [ -z $notename ]; then
echo "Invalid input."
return 0
else
cd $DEFAULT_PATH
if [ -e $notename ]; then
echo "File was found in your Notes folder."
@ -19,6 +24,7 @@ function findnote() {
echo "Try 'findmisplacednote' to find the original file."
fi
cd $DIR
fi
cd $DIR
}

View file

@ -16,9 +16,15 @@ 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 [ -z $input ]; then
echo "Invalid input."
return 0
else
if [ $input = 1 ]; then
less ~/.shellnotes/logs/disfailed.txt
elif [ $input = 2 ]; then
@ -34,4 +40,5 @@ case $1 in -l|--logs )
else
echo "Invalid input."
fi
fi
esac

View file

@ -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"
}

View file

@ -11,12 +11,20 @@ function noteinfo() {
else
notename=$1
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
else
echo "That note doesn't exist."
fi
fi
fi
cd $DIR
}

View file

@ -6,19 +6,26 @@ in /docs/github/ for its full text.
info
function quicknote() {
if [ $# -eq 0 ]; then
if [ $# -eq 0 ]; then
echo -n "Enter note name: " && read notename
else
else
notename=$1
fi
cd $DEFAULT_PATH
if [ -e $notename ]; then
fi
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
else
touch $notename
$QUICK_NOTES_EDITOR $notename
cd $DIR
@ -27,9 +34,9 @@ else
underlines=$(echo "$str" | tr -c '\010' '-')
echo "$str\n$underlines"
fi
fi
case $readquicknote in y|Y|YES|Yes|yes )
case $readquicknote in y|Y|YES|Yes|yes )
clear
cd $DEFAULT_PATH
if [[ -e $notename ]]; then
@ -37,6 +44,9 @@ case $readquicknote in y|Y|YES|Yes|yes )
else
echo "This note is blank."
fi
esac
esac
fi
cd $DIR
}

View file

@ -12,6 +12,12 @@ function readnote() {
notename=$1
fi
if [ -z $notename ]; then
echo "Invalid input."
return 0
else
cd $DEFAULT_PATH
if [ -e $notename ]; then
chmod 0444 $notename
@ -30,5 +36,5 @@ function readnote() {
clear
cd $DIR
fi
}

View file

@ -15,6 +15,19 @@ function renamenote() {
newnotename=$2
fi
if [ -z $notename ]; then
echo "Invalid input."
cd $DIR
return 0
elif [ -z $newnotename ]; then
echo "Invalid input."
cd $DIR
return 0
else
if [ -e $notename ]; then
if [ -e $newnotename ]; then
echo "There is another note named '$newnotename' in your Notes folder."
@ -31,4 +44,6 @@ function renamenote() {
fi
cd $DIR
fi
}