Skip to content

Conversation

@eklitzke
Copy link

@eklitzke eklitzke commented Apr 4, 2019

I found the whole behavior about unsetting DISPLAY to disable GUI dialogs to be really confusing, since I can't think of any other Unix CLI programs that automatically pop up GUI dialogs this way. The lpf usage documents the behavior, but for some reason by brain looks to the top of the command synopsis/usage first when looking for how to change program behavior, and it took me way too long to see the note about unsetting DISPLAY at the bottom of the usage string.

This change uses the Bash getopts builtin to:

  • Add a -n flag that automatically unsets DISPLAY
  • Invoking with -h will show usage and exit (as is currently the case), but now the exit code in this situation will now 0.

After parsing -h or -n the getopts code will shift the arguments and fall through to the existing command parsing code. I also updated the man page and usage string.

Note that this uses the getopts shell builtin, not the external getopt command, so this change does not introduce any additional dependencies as it uses a feature already built into Bash itself. Maybe the lack of getopts in lpf is an intentional style choice, so take this as you will, but I consider this to be more Unixy and intuitive.

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