Closed raphaelcohn closed 10 months ago
Pretty sure there is no need to do that even on Windows. stdout
is in text mode by default and will translate it to \r\n
under the hood.
Help messages can be output to either standard out or standard error - which depends on why help is being displayed (--help
should place it on standard out; a parsing failure should place it on standard error as any process piping the output from the failing process will not get garbage, potentially propagating errors).
So one can have different behaviour depending on the terminal attached to standard out or standard in; indeed, there may not be a terminal attached at all. A better strategy is probably to check the attached file handles, but that would limit support to LuaJIT.
A further complication can arise on some Mainframe platforms, where there's another kind of newline... A nice touch would be to allow an user of cliargs to control the newline strategy, and then it all becomes moot.
@raphaelcohn would you check if the new option in the PR suits your use-case? It allows you to customize the newline char (e.g. to use \r\n
or whatever else you need.)
Thanks
@raphaelcohn I know it has been a while, but I came on to do some maintenance and om reviewing PRs. This issue got a PR to go with it 2 days after you reported, but it never got any feedback. 5 years later the PR is still sitting around and I'm inclined to think this is not an actual issue. I'd be happy to learn that I'm wrong here but plenty of apps use this as-is without fiddling with line ending with some degree of success.
I'm happy to revive the PR and adapt it to merge if that approach is going to fix somebodies real problem. Keep in mind it would be up to the calling app to determine what line endings to set up, no detection of the output environment is being done.
There's plenty of cross-platform stuff, and I've never seen anyone do this. So wondering if this is a real problem...
my 2cts; close it, if it becomes an issue later, we can reopen.
For maximum platform compatibility (especially Windows), change the use of
\n
to a platform-specific value