How may I detect the name of the directory (or better yet the entire path) in which my shell script is run?
what shell? What operating system?
For starters try
man pwd $PWD