I am new to bash scripting but after trying several syntax approaches and researching, I am a bit stuck storing the result of an external script call in my bash script. $r has no visible value when I echo it...
From the command line, it works as expected:
./external-prog 23334
echo $?
2
#!/bin/bash
# build the command
c="./external-prog 23334"
# invoke command that returns an integer value
eval "$c"
#collect result in $r
r=$(eval "$?")
#see result
echo $r