Skip to content

test: Trying to add switches to display help information for a function, but fish treats the "-h" argument strangely. #2332

@audreytoskin

Description

@audreytoskin

I'd like my function to display help information if there are no arguments, or if the first argument is either -h or --help.

function foo
    if test -z "$argv"  -o "$argv[ 1 ]" = "-h"  -o  "$argv[ 1 ]" = "--help"
        echo "help"
    # Else if there are other arguments, do something else...
    end
end

This seems to work correctly when there are no arguments, or if the first argument is --help, but sending -h returns an error:

test: Expected a combining operator like '-a' at index 5

I'm running fish on Fedora 22 x64. I've tried this on both the version available in the Fedora repos (2.1.1) and from compiling the latest release (2.2.0).

Metadata

Metadata

Assignees

Labels

bugSomething that's not working as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions