leamas / lpf

lpf - Local Package Factory
MIT License
61 stars 6 forks source link

Add -n flag to unset DISPLAY #36

Open eklitzke opened 5 years ago

eklitzke commented 5 years ago

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:

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.