Would appreciate if someone can explain the ${0##/} line. What does it do?
I am aware that $0 is the script name, $# is number of arguments passed in, $ is all the arguments. With the curly brackets {} added in, what's the eventual effect?
Does ${0##/} actually equals $0$#$? (something like factorising?)
This is a parameter expansion implemented by ksh, bash and possibly other shells and documented in these shell respective manual pages which I recommend you to read.
It means here remove all directory components that might appear in $0. It is equivalent to using `basename $0` but faster.