bash-numpad-input icon indicating copy to clipboard operation
bash-numpad-input copied to clipboard

Greatly improve script

Open saloniamatteo opened this issue 4 years ago • 4 comments

  • Converted all "echo" commands to "printf"
  • Use [[ CONDITION ]] && doSomething instead of if [ CONDITION ];then doSomething
  • Use Regex to check if input is number ($inpIsNum)
  • Check if folder numpadInput exists in current directory, so it won't give an error if it does not
  • Fix syntax:

from

while true; do
    doSomething
done

to

while true
do
    doSomething
done

Please check if this works before merging into master branch, as I currently can't use a computer. (I wrote this using Termux on android, it does not have tput)

saloniamatteo avatar Jul 09 '20 15:07 saloniamatteo

why would you change the while loop syntax?

neektwothousand avatar Jul 10 '20 04:07 neektwothousand

@neektwothousand I think it's better like this. However, if @TDGalea wants to keep the old syntax, it's fine, as both work nonetheless.

saloniamatteo avatar Jul 10 '20 08:07 saloniamatteo

Hi both. I did start rewriting the script from scratch taking most of these changes into account, but now I've just realised I had that on my laptop's RAM disk, which I usually never shut down to preserve, but last night did so. Oops.

The only thing I won't be changing is having "do" on a separate line, as in my personal opinion that's just using up more line space for no reason. Obviously this is down to what we're all used to.

Once it's done again I'll test and publish if all goes well. Thanks for the work, @GoDzM4TT3O

I'm about to go on a four hour drive so I'll likely end up writing it on my phone also, although I'll do it over SSH to the server it's running on.

TDGalea avatar Jul 10 '20 08:07 TDGalea

Ok, I'll change again the loop syntax so that you can merge my branch into the master branch.

saloniamatteo avatar Jul 10 '20 08:07 saloniamatteo