Hello Aaron,
the idea of removing the line ends comes from copying other unix tools
behavior. Also reappending a line ending should result in the standard
line ending for the platform used. So th eproblem is actually working
with input from another platform. I won't change the standard behavior
of the -R/-F switch but could probably add it a new switch which would
stop removing the trailing new lines.
marcus
Tuesday, May 4, 2004, 10:46:29 AM, you wrote:
> Greetings!
> I've been exploring the work done on the PHP CLI sapi, and am impressed
> with the new features that are in PHP 5.
> One thing that I am a bit troubled about is the behaviour of the -R
> switch in that it removes the trailing \n and \r line end characters
> when it delivers the line to $argn. I can't see any useful reasons for
> it doing this, and it does not handle STDIN the way it should.
> The following file should just pass through the following code, not
> strip out all the line ends:
> cat file.txt | php -R 'echo "$argn";'
> I realize that one possible reason that this was included was because
> it is simpler to add a line end if needed then to chomp it. However,
> even if I do use:
> cat file.txt | php -R 'echo "$argn\n";'
> if the file uses \r\n line ends, it still changes the file. And it's
> unacceptable to have to know what type of file it is when doing a
> command as simple as that.
> Curt Zirzow provided me with the patch that I'm including, and would
> like to ask that the behaviour be changed before the PHP 5 final.
> I realize that this has been working like this for over a year, and by
> making this change we would be breaking backwards compatibility (with
> pre version 5 releases). However, since I do believe that this behaviour
> is wrong, I feel that it would be a mistake to let it get into the PHP 5
> final, as it will need to get changed sooner or later, and if it is
> introduced into PHP with version 5 then it will be much harder to reverse.
> I'm sorry if I'm ranting a bit. I am known to miss obvious things, so
> if it's my mistake and there is a good reason for the behaviour, please
> let me know. I appreciate all the work that has gone into PHP 5, I'm
> enjoying it throughly!
> Aaron
--
Best regards,
Marcus mailto:[EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php