----- Original Message -----
From: "dthacker"
Newsgroups: comp.unix.sco.misc
To:
Sent: Thursday, June 26, 2008 4:58 PM
Subject: rusty at shell functions


> I'm back at the shell for scripting, without my beloved perl or even
> bash. I'm having a horrible time with shell functions, so I reduced
> it to this test case. What am I doing wrong? SCO 5.05


There are several custom-installable packages of perl 5 that can be installed on 505.
There is also ksh already on the system which is much more functional (ah, pun not intended) than the plain sh.
It's safe to use ksh, it's stock since the later versions of xenix and it's on every box.

There are also several packages and standalone binaries of ksh93, bash, zsh.

You do not lack for scripting languages unless the site is only accessed by carrying floppies on foot through zombie hordes.


But, as for this:

> #!/bin/sh
> echo "calling function foo"
>
> foo "Dave"
>
> foo () {
> echo "$1 is not here"
> return 0;
> }
>
> # ./test.sh
> calling function foo
> ./test.sh: foo: not found


Shells read scripts from the top down and evaluate & execute things as they are encountered.

So, to use a function, first you define, then you use.

---
#!/bin/sh
foo () {
echo "$0: $@"
}

foo well hello there
---

--
Brian K. White brian@aljex.com http://www.myspace.com/KEYofR
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!