Skip to main content
retagging
Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
added 20 characters in body
Source Link

The command patch -R -p0 -s -f --dry-run < abc.patch fails with exit code 1 and prints a error message from patch command but when used with negation in a if condition it passes (i.e prints yesPass), below is the code

if ! patch -R -p0 -s -f --dry-run < abc.patch; then
         echo "Pass"
fi

What I tried ? I redirected string dev/null no change in result

Please help me understand what's going wrong in here ?

The command patch -R -p0 -s -f --dry-run < abc.patch fails with exit code 1 and prints a error message but when used with negation in a if condition it passes (i.e prints yes), below is the code

if ! patch -R -p0 -s -f --dry-run < abc.patch; then
         echo "Pass"
fi

What I tried ? I redirected string dev/null no change in result

Please help me understand what's going wrong in here ?

The command patch -R -p0 -s -f --dry-run < abc.patch fails with exit code 1 and prints a error message from patch command but when used with negation in a if condition it passes (i.e prints Pass), below is the code

if ! patch -R -p0 -s -f --dry-run < abc.patch; then
         echo "Pass"
fi

What I tried ? I redirected string dev/null no change in result

Please help me understand what's going wrong in here ?

Source Link

Why the Unix command exit with non-zero value in Shell and evaluates to True when used in bash if condition?

The command patch -R -p0 -s -f --dry-run < abc.patch fails with exit code 1 and prints a error message but when used with negation in a if condition it passes (i.e prints yes), below is the code

if ! patch -R -p0 -s -f --dry-run < abc.patch; then
         echo "Pass"
fi

What I tried ? I redirected string dev/null no change in result

Please help me understand what's going wrong in here ?