here's what i'm trying to achive:
function f1() { return 0 } function f2() { return 0 } if [[ f1 && f2 ]]; then echo "success" else echo "fail" fi
It depends. If words is a Set that already contains an equal object, it won't add it. Please read the doc before asking this kind of question. By the way when you call a function whether it's in a statement (if, try ...) the function is still called and the body executed so yes the obj will be addded to words.
In the myScript.sh file, we've defined a variable VAR and two functions: log_info() and log_error(). We can call the functions within the script file.
Functions in Bash also support recursion (the function can call itself). For example, F() { echo $1; F hello; sleep 1; } . A recursive function is a function that calls itself: recursive functions must have an exit condition, or they will spawn until the system exhausts a resource and crashes.
You don't use [[
(or [
) when running a command and checking the result code.
if f1 && f2 ; then echo "success" else echo "fail" fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With