Today, I have to check the existence and the number of input arguments. I have the following script:
#!/bin/bash
echo "*** Test ***"
echo
echo $#
echo $*
function test1(){
echo "test"
}
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
else
test1
fi
function GetTime()
{
echo "Get Time function"
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
else
test1
fi
}
When I enter ./test.sh GetTime I get
*** Test ***
1
GetTime
test
Get Time function
Illegal number of parameters
I do not understand why the behavior is different between the first condition and the one contains within the GetTime() function. Somebody could help me ?
Thank in advance
GetTime()
even being called? – GreenAsJade Nov 17 '14 at 15:03