function: not found error on solaris

shell script in very simple,

#!/bin/sh
function msgs
{
        echo 'this'
}
msgs

It works on linux, apple, but can not run on solaris. On solaris, when I enter "./t.sh", it gave me following error,

./t.sh: function: not found
this
./t.sh: msgs: not found

What's wrong with this simple script on solaris? Can anybody tell me? Thanks.

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

Looking at the Solaris man page for Bourne shell (sh) I cannot see function, what I do see is this form for defining a function:

Msg() {
	echo "$*"
}

I would usually script using Korn shell (ksh) the manpage for which does show the use of "function" to define a function.

I see. Thank you very much.