0


We got a script that we need to understand, and at some point, we got this syntax:

if  [ "$PASS_CHAINE" = "TRUE" ]
then echo "Launching DEGAGEMENT" | SLog
     cd $INTERFACE_D/bin_cm/deg
     $INTERFACE_D/bin_cm/deg/lance_deg 2>&1 ; echo "{@@##}RETURN_REAL_STATUS_SCRIPT=${?}" | SLog
     EXIT_CODE=$?
     if [ $EXIT_CODE -ne 0 ]
     then echo "Error in DEGAGEMENT" | SLog
          exit_script
     fi
 fi

I'm confused about the echo "{@@##}" part, I don't really understand it. I know the scripts tries to test the return code of the lance_deg function, but it won't work because it's gonna get the return code of the echo command.

I can remove the echo part to solve my problem, but the point is really to understand what the {@@##} part means.

  • echo "{@@##}" prints those 6 characters, there's no special meaning – glenn jackman Sep 2 '15 at 14:50
4

That part:

echo "{@@##}RETURN_REAL_STATUS_SCRIPT=${?}"

Just prints:

{@@##}RETURN_REAL_STATUS_SCRIPT=x

where the last x is replaces by the value of variable $?. From the bash manpage:

   ?      Expands to the exit status of the most recently executed foreground pipeline.

That means that $? contains the exit code of the previously executed command: $INTERFACE_D/bin_cm/deg/lance_deg, which can be a digit from 0; for success and 1 or geather for an error.

See this:

$ ls file
file
$ echo $? # 0 indicates success
0
$ ls file_not_exist
ls: cannot access file_not_exist: No such file or directory
$ echo $? # >0 is an error
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.