Re: bash subroutine syntax question
- From: "lovecreatesbeauty@xxxxxxxxx" <lovecreatesbeauty@xxxxxxxxx>
- Date: Thu, 30 Oct 2008 23:36:25 -0700 (PDT)
On Oct 31, 9:21 am, ToddAndMargo <ToddAndMa...@xxxxxxxxxxxxxxxxxx>
wrote:
Hi All,
Just a trivia question. In bash subroutines
My Subroutine () {
The blank in the name My Subroutine causes a syntax error. It's good
that you already corrected it in later posts.
...
}
Does anything go inside the "()"?
There's an alternative way to compose a function header. The shell
function doesn't require its formal parameters to be listed when it's
defined. See
$ man sh
for more.
$ cat a.sh
#!/bin/sh
f1()
{
echo f1: arg num: $#, args: $*
}
function f2
{
echo f2: arg num: $#, args: $*
}
f1 $*
f2 $*
$ sh a.sh aa bb
f1: arg num: 2, args: aa bb
f2: arg num: 2, args: aa bb
$
.
- References:
- bash subroutine syntax question
- From: ToddAndMargo
- bash subroutine syntax question
- Prev by Date: Re: why cpu MHz in /proc/cpuinfo different from model spec?
- Next by Date: Re: bash subroutine syntax question
- Previous by thread: Re: bash subroutine syntax question
- Next by thread: Re: bash subroutine syntax question
- Index(es):