phunni Posted July 13, 2006 Report Share Posted July 13, 2006 OK, I'm trying to write a bash script - so I googled a couple of tutorials and got started. The first thing I wanted to do was to write a simpel function - all the tutorials seemed to suggest I could. So, to test the concept I wrote the following: #!/bin/bash echo "Thanks for coming..." finish function finish() { echo "done..." EOF } When I attempt to run this I get: Thanks for coming... ./myuwefit.sh: line 8: finish: command not found So, what am I missing here...? Quote Link to comment Share on other sites More sharing options...
neddie Posted July 13, 2006 Report Share Posted July 13, 2006 It seems that The function definition must precede the first call to it. There is no method of "declaring" the function, as, for example, in C. (from the advanced bash guide). So it checks it line by line, and when you call it, it doesn't know what it is. If you define it and then call it, then it knows what to do. ;) Quote Link to comment Share on other sites More sharing options...
phunni Posted July 13, 2006 Author Report Share Posted July 13, 2006 Amazing what small, but crucial, things you can so easily miss... Thanks - that's solved it... Quote Link to comment Share on other sites More sharing options...
neddie Posted July 13, 2006 Report Share Posted July 13, 2006 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.