CleverCloud / clever-tools

The official command line interface for Clever Cloud
https://www.clever-cloud.com/
Apache License 2.0
73 stars 46 forks source link

command exits 0 even if [ERROR] occurs #226

Closed Nigui closed 6 years ago

Nigui commented 6 years ago

I'm creating a bash script using clever commands.

I want to test if command ends well or not (i.e. exits with error code 0 or + ).

For exemple, with this script :

#!/bin/bash

clever link anapp 

if [ $? -eq 0 ]
then
  echo "Success"
else
  echo "Fail" >&2
fi

outputs :

[ERROR] Application not found
Success

Event if I haven't anapp app on clever cloud.

It means that clever link ... does not exit with a code > 0 when error occurs.

You can replace clever linkby any other command.

Nigui commented 6 years ago

For the ones interested, I'm bypassing with :

#!/bin/bash

out=$(clever link anapp 2>&1)

if [ $out =~ "Error" ]
then
  echo "Fail" >&2
else
  echo "Success"
fi
hsablonniere commented 6 years ago

Hey @Nigui, we're about to release a big refactor that really exits with Linux error codes. I'm closing this issue and I'll let you follow this one: https://github.com/CleverCloud/clever-tools/issues/202