following code gives error "foo:return: too many arguments"
f123() { echo $1; return 1; }
f124() { echo $1; return 1; }
foo() {
return f123 "hello" && f124 "world"
}
foo
requirement is:
- I want foo to execute f124 only if f123 returns non-zero return value
- I want foo to return the return value of the last command that was successfully executed with non-zero return code
How do I do this in bash?
false ; foo $?? Good luck.$?(now that I understand your code better). Good luck.