The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 06-25-2009
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 717
Hi.

As long as one obeys the syntax rules, many forms are possible:

Code:
#!/usr/bin/env ksh

# @(#) s1	Demonstrate syntax allowed for shell functions, ksh.

echo
export LC_ALL=C
echo "Environment: LC_ALL = $LC_ALL"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1)
echo

one()
{
  echo " One called." >&2
  return 0
}

two(){
  echo " Two called." >&2
  return 0
}

three(){ echo " Three called." >&2 ; return 0
}

four(){ echo " Four called." >&2 ; return 0 ; }

echo
echo " Results, calling one, two, three, four."
one
two
three
four

exit 0

producing:

Code:
% ./s1

Environment: LC_ALL = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0 
ksh 93s+


 Results, calling one, two, three, four.
 One called.
 Two called.
 Three called.
 Four called.

Best wishes ... cheers, drl