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.
CodePudding user response:
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.