简体   繁体   中英

Man page in C application

I'm currently working on a little project to test my knowledge in writing C applications. I try to create a man page which shall open, once app --help is typed. How do I change the path, so when I send my work to friends they can also run app --help and the man page will open.

Is there any possibility to run a command from a C file like:

if (strcmp(argv[1], "--help") {
   run_in_command_line("man ./app.8");
}

Or are there other, better, ways to do it.

run_in_command_line may be a call to system() , but this will work only if run into a terminal.

Launching man ./app.8 from your executable is definitely a bad idea, because it would require that the run would be made in the right directory. Such a constraint is considered as bad. Prefer:

  • an installation procedure that will install the executable and the man,
  • use system("man app") in the code, or preferably a help command that gives basic informations and then suggests to read the man for complete information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM