How do I use subroutines in a Korn shell script? In particular can I send parameters to a subroutine?
If I have a script like this:
sub1()
{
echo this is in sub1
}
sub2(x)
{
echo this is in sub2
echo $x
}
echo script starts now
sub1
sub2(par)
echo script end
Then the sub1 routine works OK but my guess at sending a parameter (in sub2) doesn't work. In fact it seems that any way I try to call a subroutine with a parameter (or even empty brackets) fails.
Is this possible?
Thanks in advance as usual
If I have a script like this:
sub1()
{
echo this is in sub1
}
sub2(x)
{
echo this is in sub2
echo $x
}
echo script starts now
sub1
sub2(par)
echo script end
Then the sub1 routine works OK but my guess at sending a parameter (in sub2) doesn't work. In fact it seems that any way I try to call a subroutine with a parameter (or even empty brackets) fails.
Is this possible?
Thanks in advance as usual