Hi, I wish I could post here with an actual solution, but I had trouble actually finding how these line endings are generated.
The problem:
When you type `drush help | less` I get some really funky behavior I've never seen (attached screen-cast). I don't know how to describe it, other than less seems to receive each line from drush' output as if its another file... kind of... the screencast should make clear what I'm talking about.
What I Found:
So, to see if there was something funky about the stream of text passed out of drush, I did: `drush help > ~/drushelp`
then, typed `vim ~/drushhelp` -- and sure enough there's msdos line endings on every line. I don't know if this is the reason for the way `less` is receiving drush so oddly, but I figured it was a start.
Be Glad to Help:
I tried to track down how drush generates its help output, but couldn't find much. If someone would be willing to point me in the right direction, I'd love to trouble shoot this problem myself.
Any thoughts?
[ if screencast ogv fails to attach, find it here: http://dl.dropbox.com/u/9211525/drush-help-less.ogv ]
Comments
Comment #1
jzacsh CreditAttribution: jzacsh commentedI've verified that this issue doesn't happen in another distro's environment, arch linux.
I've also verified that its not _my_ config that's screwing stuff up, by testing:
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedNice movie. I can reproduce this on Ubuntu but not OSX. I'll look into help command as time permits.
Comment #3
jonhattanThis is a duplicate of #939432: Drush output terminates lines with CR/LF on linux
Comment #4
jonhattanIt seems solving #939432: Drush output terminates lines with CR/LF on linux doesn't fix this. So reopen again and set a more according title.
Comment #5
kotnik CreditAttribution: kotnik commentedNot only that, I can't "less" any of Drush' output.
Subscribing.
Comment #6
kotnik CreditAttribution: kotnik commentedIt seems that this is upstream bug, in PHP. See this: http://bugs.php.net/bug.php?id=48125
PHP devs regarded this as bogus, but it sure isn't.
Comment #7
kotnik CreditAttribution: kotnik commentedI found out more.
Culprit is not even in PHP, it seems that terminfo is a bit broken in ubuntus. Everything is working as expected in Debian Lenny.
I guess we can't do a thing in Drush.
Comment #8
jonhattanI confirm it works in debian (lenny and above) and doesn't work in ubuntu. It is not a drush thing as the same happen with symfony's cli tool.
A difference I know between debian and ubuntu php-cli's is that ubuntu one is compiled with libedit support. libedit is a (buggy) bsd-licensed clone of readline(gpl) but that's another story.
Anyone using other distros: to check if php is compiled with libedit:
kotnik: terminfo? can you elaborate on that?
Comment #9
kotnik CreditAttribution: kotnik commentedSure I can elaborate, jonhattan.
The thing is, this is not related to Drush, not a tiny little bit. *Anything* that PHP outputs in terminal in ubunuts (not sure for other distros) will suffer the same problem, so it will be the same for Symfony, Cake, whatever.
Try this:
php -r 'print_r(get_defined_constants());' | less
Terminfo is a file that describes a terminal, or is a library and database that enables programs to use display terminals in a device-independent manner, as Wikipedia says. It's maintained by none other then Eric S. Raymond. My guess is that terminfo/termcap is responsible, but it also might be ncurses/readline issue, but I really can't be sure.
I'll try to tackle this if I find some more time, but Drush can not influence this, issue is even upstream for PHP.
Comment #10
jzacsh CreditAttribution: jzacsh commentedwhoa, i totally have not been watching my drupal emails :( whoops! I can confirm this is not an issue on archlinux, just on ubuntu. comment #9 sounds right, but I'm not at an ubuntu box right now, so I can't test out the proof - will try on Monday.
Comment #11
kotnik CreditAttribution: kotnik commentedjzacsh, could you try just this on Arch:
It might be just 'buntu issue. I'll report upstream if it is.
Comment #12
jzacsh CreditAttribution: jzacsh commentedTried it on arch, definitely no issues. I will try (again) to test this tomorrow on Ubuntu (thanksgiving break -- stressful week).
Comment #13
jzacsh CreditAttribution: jzacsh commentedI've posted a thread on ubuntuforums.org, hopefully I can figure out the details of this bug, and next I will post to launchpad.net/ubuntu so that the bug can be fixed, since this seems Ubuntu-specific.
Here's the forum thread, if you have any thoughts, I think Ubuntu's forum would be the appropriate place:
http://ubuntuforums.org/showthread.php?p=10359461#post10359461
Comment #14
rfaySorry to subscribe to a closed issue, but on Ubuntu, this definitely doesn't work.
Comment #15
kotnik CreditAttribution: kotnik commentedRfay, yes, and jzacsh narrowed this issue down to Ubuntu 10.10 only (10.04 doesn't behave this way).
We'll see what will happen in 11.04.
Comment #16
rfayShucks, just installed natty narwhal 11.04 and it still has the same php+ubuntu #fail.
Comment #17
kotnik CreditAttribution: kotnik commentedYes, and for more info, here's (still open) Ubuntu bug report:
https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
FWIW, you can trick libedit by piping it /dev/null like this:
Comment #18
jzacsh CreditAttribution: jzacsh commentedSorry I haven't actually followed through to try to push my bug report further. This issue just doesn't get in my way enough and I have other things I'd rather spend time helping fix. If anyone is itching over this issue and wants to do something, I'd say try out what I mention as "current attempt" [1] and if you find anything interesting, post back here (or post as a reply on the original thread).
[1] http://ubuntuforums.org/showthread.php?p=10359461#post10393024
Comment #19
jzacsh CreditAttribution: jzacsh commentedComment #20
rfayUsing a non-ubuntu PHP build does fix this. I just installed the PPA from https://launchpad.net/~bjori/+archive/php5 and voila, all is well.
I haven't spent any time to find out what is newly broken through :-)
Comment #21
NealB-1 CreditAttribution: NealB-1 commentedYou can turn the workaround in #17 into a shell function in bash:
Then `drush_ help | less` works. Of course, you have to go back to the original if you want it to read from stdin.
Comment #22
rfaySadly, I took at look at Ubuntu 11.10 beta 2 and this problem has still not been resolved.
Comment #23
NealB-1 CreditAttribution: NealB-1 commentedIf you install the PHP .deb from debian, will it integrate properly with the ubuntu system?
I've noticed that ubuntu makes some strange choices for software. libedit instead of libreadline? mawk instead of gawk? And there is still no package for gawk 4.0. Is there anti-gnu bias?
Comment #24
rfay@NealB I used to use the packages from http://dotdeb.org with Ubuntu, but that broke somewhere along the way. Could be fixed again.... But it seems that only the *build* of the ubuntu packages is the problem.
No, I'd say there's no anti-gnu bias, but that's definitely for another forum :-)