Trying to declare parameters? Don't. Use () and refer to params as $1, $2
5if ![-z foo ]; then true; fi # if command `[-z' w/ args `foo', `]' fails..
6
7# SH-1036
8echo (foo) bar
Description
Problematic code:
foo(input) {
echo "$input"
}
foo("hello world");
Preferred code:
foo() {
echo "$1"
}
foo "hello world"
Shell script functions behave just like scripts and other commands:
* They always take 0 to N parameters, referred to with $1
, $2
etc. They can not declare parameters by name.
* They are executed using name arg1 arg2
, and not with parentheses as C-like languages.