You can use the 'alias' command instead. But this can become difficult
if you need quotes or if/then/else/endif constructs in your "function"
body.
This has been discussed recently in this newsgroup. To summarize, you
can declare "functions" quite easily if you use a meta-alias called
"make_alias" (sorry if its definition is incomprehensible).
See usage example at the end of the article.
Klaus Frank
alias make_alias '\\
<<"end_alias" sed -e '"'"'\\
#\\!/bin/sed -f\\
#\\
## Make the eval command\\
# quote quotes\\
s/'"'"'"'"'"'"'"'"'/'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'/g;\\
# enclose with quotes\\
1s/^/eval '"'"'"'"'"'"'"'"'/;\\
$s/$/'"'"'"'"'"'"'"'"'/;\\
#\\
## Make the alias command\\
# escape exclamation marks and newlines\\
s/\\!/\\\\!/g;\\
s/$/\\\\/g\\
# quote quotes\\
s/'"'"'"'"'"'"'"'"'/'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'/g;\\
# enclose with quotes\\
1s/^/alias @alias_name@ '"'"'"'"'"'"'"'"'/;\\
$a\\\
;echo >/dev/null'"'"'"'"'"'"'"'"'\\
#^^^^^^^^^^^^^^^ (workaround against printing of arguments)\\
'"'"' | \\
sed -e s/@alias_name@/\!\!:1/ >/tmp/make_alias$$; \\
source /tmp/make_alias$$; \\
rm /tmp/make_alias$$; \\
'
make_alias example
echo -n 'starting command "!!:1" .....'
if ( { !!:1 } ) then
echo ok
else
echo fail
endif
"end_alias"
example true
example false