Bug 1014692 - some rhc client commands return wrong exitstatus when running from ruby
some rhc client commands return wrong exitstatus when running from ruby
Product: OpenShift Online
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
Unspecified Unspecified
unspecified Severity medium
: ---
: ---
Assigned To: Clayton Coleman
libra bugs
Depends On:
  Show dependency treegraph
Reported: 2013-10-02 10:35 EDT by Oleg Fayans
Modified: 2016-11-30 19:27 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-10-17 09:33:25 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Oleg Fayans 2013-10-02 10:35:52 EDT
Description of problem:
When I run rhc authorization -h --server [server.fqdn] from the irb shell, the exitstatus is 1 instead of 0

Version-Release number of selected component (if applicable):
reproduced with rhc-1.14.6 and rhc-1.15.4 on ruby-1.9 and ruby-2.0

How reproducible:

Steps to Reproduce:
1. launch irb
2. > `rhc authorization -h --server someserver.example.com`
3. > puts $?
Actual results:
#<Process::Status: pid 21989 exit 1>

Expected results:
#<Process::Status: pid 22022 exit 0>

Additional info:
When I run 
> `rhc authorization -h`
then I get 
#<Process::Status: pid 22022 exit 0>

The same problem is when I run this command using Open3.popen2e(cmd), where cmd is the rhc command

This bugs is an obstacle for writing the automated tests of the rhc
Comment 1 Clayton Coleman 2013-10-02 14:09:33 EDT
So there are two bugs here.

1) rhc authorization -h should display the help page for help, not display the list of commands.  The exit code 1 is actually correct for the list of commands (trying to find help for a command that does not exist), but since rhc authorization actually exists the list of commands should not be shown.

2) The pager function is what is causing the exit code to be 0, which is incorrect.  We fork rhc and then exec less in order to get paging to start, but the exit code of RHC is being lost (it was supposed to be 1).

Fixing both issues.
Comment 2 Clayton Coleman 2013-10-02 15:19:20 EDT
Why are you trying to run -h?  Did you mean to run 'rhc authorization --server ..." instead?
Comment 3 Clayton Coleman 2013-10-02 15:31:23 EDT
Fixed #1 above as https://github.com/openshift/rhc/pull/472 - please spawn a bug for #2
Comment 4 openshift-github-bot 2013-10-02 18:20:52 EDT
Commit pushed to master at https://github.com/openshift/rhc

Bug 1014692 - rhc authorization -h should display help page

Was not detecting exact matches correctly.
Comment 5 Peter Ruan 2013-10-03 15:27:15 EDT
verified with devenv_3859

irb(main):002:0> `rhc authorization -h --server ec2-54-221-164-39.compute-1.amazonaws.com`
=> "Usage: rhc authorization \n\nShows the full list of authorization tokens on your account. You can add, edit, or delete authorizations with subcommands.\n\nAn authorization token grants access to the OpenShift REST API with a set of privileges called 'scopes' for a limited time.  You can\nadd an optional note to each authorization token to assist you in remembering what is available.\n\n\nGlobal Options\n  -l, --rhlogin LOGIN       OpenShift login\n  -p, --password PASSWORD   OpenShift password\n  --token TOKEN             An authorization token for accessing your account.\n  --server NAME             An OpenShift server hostname (default: openshift.redhat.com)\n  --timeout SECONDS         The timeout for operations\n\n  See 'rhc help options' for a full list of global options.\n\nList of Actions\n  add           Add an authorization to your account\n  delete        Delete one or more authorization tokens\n  delete-all    Delete all authorization tokens from your account\n  list          Show the authorization tokens for your account\n\nThe default action for this resource is 'list'\n\n"
irb(main):003:0> $?
=> #<Process::Status: pid 12775 exit 0>

Note You need to log in before you can comment on or make changes to this bug.