Ok ... let us start at the beginning:
1. Please place code in [code][/code] tags so it can be read better and formatting is kept.
2. bash is a top down language, meaning you have a line:
The issue here is dname has not been set yet so directory_name will always be blank.
3. You need to provide more information to the user. You have asked for a directory name when in fact it is relative, meaning that any directory given must be in the current directory
to be accessed. Is this what you intended?
4. The following code does not make sense to me:
cd $dname ; ls -sail | head
echo "requested changes have now been applied as below"
a. Are we interested in the directory or its contents?
b. head will just return everything from the ls command so what is the point?
c. requested changes have now been applied as below
... what changes? nothing has been done yet. Maybe it is a grammatical error here.
d. cd into the same directory again which implies that a directory with the same name is inside the one you already went into .. is this correct? if not this line will throw an error.
e. Now you call a command which is trying to change the permissions on yet another directory or file with the same name as the original directory??? Again I am not sure this is what you want.
5. Lastly, the function does the same pointless ls / head combination.
Now I know i didn't specifically answer any questions, but if you look into the above it should help you toward an answer.
I am happy to answer any further questions if you have them based on what I have written.