Search code examples
pipelineexit-coderubocop

What is the best EXIT status check Command that works in Rubocop, Linux and Windows servers?


I've been trying to make my pipeline (following rubocop syntax) and Linux/ Windows machines happy but for some reason I am stuck in the exit status checking. It is causing problem.

I have used the following and the below results:

$?.exitstatus - NOT OK in rubocop (syntax concerns); OK in Linux; OK in Windows

system() - OK in rubocop; OK in Linux; NOT OK in Windows (it is not recognized as an internal or external command)

$CHILD_STATUS.exitstatus - OK in rubocop; NOT OK in Linux (it needs require 'English' library); OK in Windows

I don't want to install anything in the machines. Any best way to make it all OK?

Thank you.


Solution

  • The accepted way is:

    require 'English'  # Capital 'E'!
    
    $CHILD_STATUS.exitstatus
    

    Note that the English lib is a standard lib that comes bundled with all versions of Ruby