I have the question:
How return the exit code from then assign :
VAR=$(command ) for ex. VAR=$(ls ....)
VAREXIT=$?
echo $VAREXIT
VAREXIT is equal to 0 if the directory exist or not exist. WHI??
if i execute the command direct from line-command , the value of $? is different if directory exist or not exist (0 or 2 )
for ex: $> ls direc./*
$> echo $?
return 2 if command return a error or 0 if command are execute without error