home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!ames!agate!bionet!uwm.edu!rpi!newsserver.pixel.kodak.com!laidbak!tellab5!vpnet!serveme!gagme!dattier
- From: dattier@gagme.chi.il.us (David W. Tamkin)
- Newsgroups: comp.unix.shell
- Subject: Re: Calling a function from a case loop.
- Message-ID: <1992Aug25.035527.25059@gagme.chi.il.us>
- Date: 25 Aug 92 03:55:27 GMT
- References: <4785@daily-planet.concordia.ca>
- Sender: usenet@serveme.chi.il.us
- Distribution: comp.unix.shell
- Organization: Gagme Public Access Seraglio, Chicago, Illinois 60656-1252
- Lines: 41
- Originator: dattier@gagme
-
- gsa@alcor.concordia.ca (a surnameless "Dan") wrote in
- <4785@daily-planet.concordia.ca>:
-
- | Has anyhone tried calling a function from a case condition?
- | This one doesn't seem to work:
- |
- | read selection
- | case $selection in
- |
- | 1)
- | call_some_funtion() ;;
- ^^
- |
- | esac
- | done
- | exit 0
- |
- | call_some_funtion()
- | {
- | echo "Hello World"
- | }
-
- First, be sure that a seventeen-letter identifier like "call_some_funtion"
- is a legal function name for your shell and your OS. You didn't tell us
- which those are.
-
- Second, if you're using sh, ksh, or bash, "()" should be only in the
- definition of the function and not in a call to it.
-
- Third, you named the function "call_some_funtion" with no c before the t.
- You spelled it the same way both places in your post, but did you spell it
- the same way both times when you tried it?
-
- Fourth, when the script is scanned (at least sh and ksh can work this way)
- the function was called at a place where it wasn't yet defined. Try putting
- the function definition at the beginning of the script.
-
- Good luck. I know it can work; I've done it.
-
- David W. Tamkin Box 59297 Northtown Station, Illinois 60659-0297
- dattier@gagme.chi.il.us CompuServe: 73720,1570 MCI Mail: 426-1818
-