C_id=${1:--1} && f_id=${2:--1} && [ ${C_id} -eq -1 ] && Sintaxis
Syntaxis is a function
please make me understand what above statement is doing
and also explain : &&
C_id=${1:--1} && f_id=${2:--1} && [ ${C_id} -eq -1 ] && Sintaxis
Syntaxis is a function
please make me understand what above statement is doing
and also explain : &&
${var:-word}
If var exists and isn't null, return its value .. otherwise return word.
&& check if previous command successfully run (mean exit status is zero) then go for next command.
This probably does the following:
---------- Post updated at 04:02 PM ---------- Previous update was at 03:37 PM ----------
And regarding "&&",
&& and || are the shell construct. which applies the action based on the success or failure of the previous commands.
cd abc && echo "change dir successfully" || echo "failed to change dir"
In the above code,
if "cd" si successful to change i.e exit code is zero. this will execute the command after "&&". if it failed to change dir, the commands after "||" will be executed.
Maybe if it's written another way
if [ -z "$1" ]
then C_id=-1
else C_id=$1
fi
if [ -z "$2" ]
then f_id=-1
else f_id=$2
fi
if [ ${C_id} -eq -1 ]
then Sintaxis
fi