Hacker News new | ask | show | jobs
by anonymousiam 661 days ago
I've done this too, but you should remove the path elements from the argv[0] string before you include it in your error/help messages.
2 comments

Sometimes you want it, sometimes you don't, so it needs to be in there, and sometimes you remove it yourself if your context of the moment doesn't want it.

And neither the want-it nor the don't-want-it case is such an outlier that you can disregard and not serve that case.

Sometimes you're talking to the user about general usage and the full path is a distracting detail and not the important part of the message.

Sometimes the full path and truthful invoked filename are an unnecessary security disclosure like telling a web viewer details about the server.

Sometimes the full path and truthful invoked filename is a necessary fact in debugging, or in errors, or even ordinary non-error logs that aren't public.

You don't need to. Keeping them shows the user exactly how to call the program based on how they called it.