1

I'm trying to make some sort of GUI for the zsh/bash terminal, just as a fun learning project, but most commands in zsh/bash need you to put in some sort of extra input, alongside just the command. Is there a way to get this info and parse it with any programming language, so I can get the user to give all the input needed without them needing to know how the command works (they will likely need to know a little, though)? Here's what I've found so far:

  • I can get all the execs from usr/bin, and open their hex.
  • I can find this location using the which command.
  • I think there is a tool in the same location that can read the hex? (debinhex.pl)
  • Some commands have a help command, but they all work differently.
3
  • I'm quite sure this has come up before. I didn't find a previous question though, most likely it remained unanswered and got auto-deleted.
    – nohillside
    Commented Apr 27, 2023 at 7:14
  • There is no standardized way to do this. GNU tried to make access to their tools kind of uniform by allowing the option --help , which then prints a usage summary, but if there is a program in /usr/bin which does not follow this guideline, you are out of luck. Even worse, you are on a Mac, and the GNU tools are not installed there by default (they can be installed via homebrew), so you won't even have much success with --help either. You could of course fetch the man page, but nobody guarantees the existence of a man page for a certain program. Commented Apr 28, 2023 at 9:09
  • While there is no standard (and if there would be one, you don't know in advance which programs follow this standard), a convention is that command line tools come with a man-page. Therefore you can try a man COMMAND, but there is of course no guarantee for the existence of such a page. Furthermore, if you have different versions of a program on your computer, you have to make sure to call up the matching man-page. Commented May 17, 2023 at 11:57

1 Answer 1

0

The explanation of the various zsh/bash commands builtin the shell itself as well as of any Unix binaries residing anywhere in PATH can be found in the respective man page (so man bash gives you the manual page for bash, man ls gives you the manual page for ls). The text source of these manual pages is in /usr/share/man (at least for the standard set of commands) but formatted more for visual rendering than for automatic parsing (so there is no easy way to derive command options out of them). I also don't see an automated way to handle commands with conflicting options (even rm has those).

So you might be better off by limiting your GUI to a small set of commonly used commands, build user guidance for those and refer to the man pages for others.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .