A function in shell script,how can i get the right result

there is a directory /data/users/osa/psidp/dmp/files/cimdir ,it have some subdirectories ,and also the subdirectoriy have it's subdirectoriis.
I want to get all the leaf nodes of the directory path .
but the result of the script is wrong ,how can i get the right result

somebody who can help me !!!!

the script name is fw.sh :

hanshu()
{
dirnum=`find $1 -type d|wc -l`
if [ $dirnum != 1 ]; then
set -A subDir `ls -l $1| awk '{if (substr($0,1,1)~"d") print $8}'`
typeset -i i
i=0
while [ $i -lt $dirnum ]
do
subDir[$i]=$1"/"${subDir[$i]}
hanshu ${subDir[$i]}
if [ "${subDir[$i]}" != "" ]; then
echo "/"${subDir[$i]}
fi
i=`expr $i + 1`
done
fi
}
hanshu $1

for example,when i run

fw.sh /data/users/osa/psidp/dmp/files/cimdir

i want get the value is :
//data/users/osa/psidp/dmp/files/cimdir/scm/1.04
//data/users/osa/psidp/dmp/files/cimdir/scm_version
//data/users/osa/psidp/dmp/files/cimdir/version

but the anwser is :
//data/users/osa/psidp/dmp/files/cimdir/scm/1.04
//data/users/osa/psidp/dmp/files/cimdir/scm/1.04

how can i get the right result what i want?
thanks!

There are special rules and a certain template to complete for posting homework. This isn't it. Thread closed.