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

jzacsh’s picture

Title: msdos line endings » arch linux
Component: Code » PM (dl, en, up ...)

I'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:

  • moving my .bashrc and .bash_profile (so they can't be called)
  • trying to duplicate this issue in a tty and rxvt
  • successful duplication.
moshe weitzman’s picture

Version: 6.x-2.0-alpha2 »
Component: PM (dl, en, up ...) » Core Commands
Status: Needs work » Active

Nice movie. I can reproduce this on Ubuntu but not OSX. I'll look into help command as time permits.

jonhattan’s picture

Status: Active » Closed (duplicate)
jonhattan’s picture

Title: arch linux » `drush help | less` doesn't work (video inside)
Status: Closed (duplicate) » Active

It 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.

kotnik’s picture

Not only that, I can't "less" any of Drush' output.

Subscribing.

kotnik’s picture

It 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.

kotnik’s picture

Status: Active » Closed (won't fix)

I 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.

jonhattan’s picture

I 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:

$ ldd /usr/bin/php |grep libedit
	libedit.so.2 => /usr/lib/libedit.so.2 (0x00718000)

kotnik: terminfo? can you elaborate on that?

kotnik’s picture

Sure 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.

jzacsh’s picture

whoa, 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.

kotnik’s picture

jzacsh, could you try just this on Arch:

php -r 'print_r(get_defined_constants());' | less

It might be just 'buntu issue. I'll report upstream if it is.

jzacsh’s picture

Tried it on arch, definitely no issues. I will try (again) to test this tomorrow on Ubuntu (thanksgiving break -- stressful week).

jzacsh’s picture

I'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

rfay’s picture

Sorry to subscribe to a closed issue, but on Ubuntu, this definitely doesn't work.

kotnik’s picture

Rfay, 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.

rfay’s picture

Title: `drush help | less` doesn't work (video inside) » `drush help | less` doesn't work on Ubuntu 10.10+ (video inside)

Shucks, just installed natty narwhal 11.04 and it still has the same php+ubuntu #fail.

kotnik’s picture

Yes, 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:

php -r 'print_r(get_defined_constants());' < /dev/null | less
jzacsh’s picture

Sorry 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

jzacsh’s picture

Issue tags: +drush, +terminal, +LESS
rfay’s picture

Using 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 :-)

NealB-1’s picture

You can turn the workaround in #17 into a shell function in bash:

function drush_() {
drush "$@" < /dev/null
}

Then `drush_ help | less` works. Of course, you have to go back to the original if you want it to read from stdin.

rfay’s picture

Sadly, I took at look at Ubuntu 11.10 beta 2 and this problem has still not been resolved.

NealB-1’s picture

If 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?

rfay’s picture

@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 :-)