Re: passing parameter to shell function as in the normal unix commands (not positional parameter)

From: Bill Marcum (bmarcum_at_iglou.com.urgent)
Date: 08/30/04


Date: Mon, 30 Aug 2004 14:57:38 -0400

On 30 Aug 2004 10:47:32 -0700, Prince Kumar
  <gspk@yahoo.com> wrote:
> Hi,
>
> I have a function defined in in .profile which accepts three
> parameters.
>
> function myfn
> {
> var1=$1
> var1=$3
> var1=$3
#I assume this is a typo. :)
> }
>
> I am wondering, whether the function can be invkoded as
>
> "myfun -c var1 -d var2 -e var3"
>
> The reason, I would prefer this method, because I don't have to know
> the order of the parameters and optionally I can ignore one or more of
> the parameter and set the default value, inside the program if needed.
>
man ksh, look for "getopts".

-- 
 If quizzes are quizzical, what are tests? (Think about it)


Relevant Pages