el3ktro
March 22nd, 2006, 04:25 PM
Hello, I can't find a solution in any bash-howtos, so I hope you can help me. I have a little bash function:
function dosomething {
...
...
}
Then later on, I want to continue only if the function has been run successfully:
if dosomething; then
...
...
fi
This works good so far. Now I need the function to have an parameter. The script is called with an username as $1, and I have to hand this parameter over to the function, so I have to call the function like this:
dosomething $1
Which will hand over the first script parameter to the function, right? But, how do I do this within the "if" statement? This doesn't work:
if dosomething $1; then
I've tried several things, but nothing works. How do I do that?
Tom
function dosomething {
...
...
}
Then later on, I want to continue only if the function has been run successfully:
if dosomething; then
...
...
fi
This works good so far. Now I need the function to have an parameter. The script is called with an username as $1, and I have to hand this parameter over to the function, so I have to call the function like this:
dosomething $1
Which will hand over the first script parameter to the function, right? But, how do I do this within the "if" statement? This doesn't work:
if dosomething $1; then
I've tried several things, but nothing works. How do I do that?
Tom