Not quite clear.
Which command's exit code do you want to capture? $? is the last cmd's exit code and should always be 0 in above.
Where (and how) do you want to store whatever result you mean?
Why do you redirect stdout and stderr to /dev/null if you want some result?
Why do you use eval in above?
No I get 0 always when I don't use eval and do like $(CLI command) or `command` , using eval I am getting 0/1(tested), which is ok for my plan.
I want to store version i.e $2 that I got after awk operation
It throws error on stdout in case if the given filename does not belongs to that branch but I got your point that grep will anyway eliminate those output
I can only emphasize what RudiC has said. Generally speaking: if you ever write a line with awk and grep ending in the same pipeline you are doing something wrong. In your case
... | awk '/Version/ {print $2}' | ....
will do the same as
... | grep "Version" | awk '{print $2}' | ....
Furthermore, the eval should only be used as a very last measure. In 99% of the time it is better to avoid it. I can't even see what the purpose of it should be in your case. Care to explain what, in fact, you are trying to do (the big picture, not the syntactical problem you had)?