Is it possible to use a function in $ ((func arg? Str1: str2))?

I would like to use an instruction like this:

var=$(( func arg ? str1 : str2 ))

but bash displays a syntax error message:

syntax error in expression (error token is "arg")

I played with various forms, but can't figure out how to get it to accept a function with an argument. Any ideas?

+3
source share
2 answers

I think the correct answer is that there is no way to use the expression I was asking about. The problem is that this conditional statement can evaluate only an integer, not a string, as I wanted.

jm666 answered the question in a comment to Steve, so I gave him a vote.

+1
source
echo $(( $(seq 1) + 1 ))
2

, bash . ? iftrue: iffalse , , bash. - :

echo $(( 1 + $(true && echo 1 || echo 0) ))
2
+2