Fix argument handling in main rbenv
command
- Explicitly asking for help with `-h` or `--help` exits with 0 status and displays help on stdout. - Not providing any arguments to rbenv results in failure status and displays version and help on stderr.
This commit is contained in:
parent
8f87f43e22
commit
825de5d2e3
@ -91,12 +91,18 @@ shopt -u nullglob
|
|||||||
|
|
||||||
command="$1"
|
command="$1"
|
||||||
case "$command" in
|
case "$command" in
|
||||||
"" | "-h" | "--help" )
|
"" )
|
||||||
echo -e "$(rbenv---version)\n$(rbenv-help)" >&2
|
{ rbenv---version
|
||||||
|
rbenv-help
|
||||||
|
} >&2
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
"-v" )
|
-v )
|
||||||
exec rbenv---version
|
exec rbenv---version
|
||||||
;;
|
;;
|
||||||
|
-h | --help )
|
||||||
|
exec rbenv-help
|
||||||
|
;;
|
||||||
* )
|
* )
|
||||||
command_path="$(command -v "rbenv-$command" || true)"
|
command_path="$(command -v "rbenv-$command" || true)"
|
||||||
if [ -z "$command_path" ]; then
|
if [ -z "$command_path" ]; then
|
||||||
|
@ -4,7 +4,7 @@ load test_helper
|
|||||||
|
|
||||||
@test "blank invocation" {
|
@test "blank invocation" {
|
||||||
run rbenv
|
run rbenv
|
||||||
assert_success
|
assert_failure
|
||||||
assert_line 0 "$(rbenv---version)"
|
assert_line 0 "$(rbenv---version)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user