Jump to content
  • Advertisement
Sign in to follow this  
netresearch

REcursive fuction call in shell script problem

This topic is 3578 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is shell script I have made to lists out directory contents and filenames for any given directory (without using ls command). There is some problem in dirfunc function call which I have marked 1 is not working. Can anybody suggest what is the problem there and how should I correct it. dirfunc() { path=$1/$2 if test -d $path then echo "--------------------------------------------------------------------------------" dir=Sub-$3 echo " $dir: $path " dir $path > inven declare -a no awk 'BEGIN{ t = 0} { { for(i=1 ; i<=NF ; i++) { no[t+$i] = $i dirfunc $path no[t+$i] $dir _____________________(1)not working } t = t + NF } }' inven echo "--------------------------------------------------------------------------------" else if test -f $path then echo " $2 : File in $dir " fi fi } dirfunc /users/mti2007/apakhale/Desktop demodir.d Directory

Share this post


Link to post
Share on other sites
Advertisement
To the best of my knowledge, shell scripts do not provide local variables by default, only global variables. This makes all subroutines non-reentrant and thus recursive calls do not work.

On the other hand, I have to wonder why you're reinventing find.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!