Skip to content

Conversation

@shynur
Copy link

@shynur shynur commented Jan 5, 2026

  • set the exit code to 0 for -h (etc.)

    This is useful when writing script, e.g.,

    if ! qjs -h >/dev/null; then
        echo 'Please install QuickJS'
        exit 1 
    fi
  • make the help() function print only the help information

  • call exit(2) when encountering invalid options or missing arguments

    It is appropriate to exit with code 2 when command-line arguments are used incorrectly. (This is also the behavior of bash/make/grep.)
    https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html:

    All builtins return an exit status of 2 to indicate incorrect usage, generally invalid options or missing arguments.

- set the exit code to 0 for `-h` (etc.)
- make the `help()` function print only the help information
- call `exit(2)` when encountering invalid options or missing arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant