Opened 15 years ago

Closed 4 years ago

Last modified 4 years ago

#4361 closed bug (not reproducible)

more command don't work as expected

Reported by: phoudoin Owned by: nobody
Priority: normal Milestone: R1/beta2
Component: Applications/Command Line Tools Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: x86

Description

$ less /etc/resolv.conf
nameserver 192.168.1.1
$ more /etc/resolv.conf
$ 

Seems that the more command line tool doesn't work fine. Native Haiku, x86-gcc4-hybrid, clean build, hrev32762. But I saw this issue since few months already, should have report it sooner.

Attachments (1)

0001-fix-less-and-more-bug-see-track-ticket-4361.patch (615 bytes ) - added by eanyx 10 years ago.
patch to fix less and more problem ticket #4361

Download all attachments as: .zip

Change History (26)

comment:1 by jackburton, 15 years ago

Actually, more doesn't work if the file has only one line. I tested with

more /var/log/syslog

And I got the full output.

comment:2 by jackburton, 15 years ago

Hmm more testing shows that more is indeed, pretty broken. I can't scroll to the end of a file because it exits before 100%.

comment:3 by axeld, 15 years ago

Since less works fine, I guess this could be one of those positive error codes problems. At least it would be worth a try.

comment:4 by jackburton, 15 years ago

What's also interesting is that "more" is just a link to "less".

in reply to:  4 comment:5 by phoudoin, 15 years ago

Replying to jackburton:

What's also interesting is that "more" is just a link to "less".

But it doesn't behave the same, as less detect when he's called "more" and set "less_is_more" global flag.

comment:6 by jackburton, 15 years ago

Yep, I just noticed :)

comment:7 by korli, 15 years ago

It seems also reproducible with "less -F". When commenting the following lines in init() and deinit() in screen.c, the problem disappears.

tputs(sc_init, sc_height, putchr);

tputs(sc_deinit, sc_height, putchr);

comment:8 by phoudoin, 15 years ago

Sounds like Terminal tty don't support setting its height, no?

comment:9 by korli, 15 years ago

Adding these lines in /etc/profile workarounds this bug:

export LESS=-X
export MORE=-X

comment:10 by jessicah, 11 years ago

Wow, still not fixed! Just got caught out testing viewing my patch, wondering why my file modified with sed/grep ended up apparently empty... argh :(

comment:11 by jessicah, 11 years ago

From what I've seen on Linux, more doesn't clear what it's printed, whereas less does. However, I did notice that less -E results in no output despite a file containing less than a screenful of text. So it seems the less_is_more mode on Haiku might need to also change the terminal emulation behaviour as well.

comment:12 by siarzhuk, 11 years ago

BTW, Ctrl-Alt-C shortcut can be used to capture all characters and control codes sent by program into Terminal as raw stream. Corresponding capture log will be stored under /var/log/ The shortcut works as toggle switch - pressing it starts the capture, the next press will stop the capture.

in reply to:  11 comment:13 by siarzhuk, 11 years ago

Replying to korli:

It seems also reproducible with "less -F". When commenting the following lines in init() and deinit() in screen.c, the problem disappears.

tputs(sc_init, sc_height, putchr);

tputs(sc_deinit, sc_height, putchr);

Those are

enter_ca_mode      smcup     ti       string to start programs using cup
[...]
exit_ca_mode       rmcup     te       strings to end programs using cup

and defined in XTERM to set/unset DEC private mode 1049

CSI ? 1049h  → Save cursor as in DECSC and use Alternate Screen Buffer, clearing it first.
[...]
CSI ? 1049l  →  Use Normal Screen Buffer and restore cursor as in DECRC.

This explains observed behaviour of the 'more' program - all output just goes to alternate screen buffer and is not visible on normal buffer after the program finishes. The 'less' has the chance to show its output to user because it waits until the key pressed at the EOF. In both cases the output is not visible in the Terminal history after the programs finish.

Replying to jessicah:

From what I've seen on Linux, more doesn't clear what it's printed, whereas less does. However, I did notice that less -E results in no output despite a file containing less than a screenful of text. So it seems the less_is_more mode on Haiku might need to also change the terminal emulation behaviour as well.

Could you compare the less source code on your Linux with Haiku's one, check current values of ti/te (in case termcap used) or smcup/rmcup (in case terminfo) and LESS/MORE environment variables? Are there any ways to preset the less options?

comment:14 by kallisti5, 11 years ago

this may explain why in vim if you open a long file and scroll around eventually the lines displayed don't match what is "really" under your cursor.

This occurs in terminal, but running vim through ssh on your Haiku machine works fine.

in reply to:  14 comment:15 by siarzhuk, 11 years ago

Replying to kallisti5:

this may explain why in vim if you open a long file and scroll around eventually the lines displayed don't match what is "really" under your cursor.

I do not think so - all above described more/less behaviour works as it should in this configuration and environment. te/ti set to switch writing into alternate buffer so it is correct to not write anything into the Terminal history.

So you observe different issue, I think.

This occurs in terminal, but running vim through ssh on your Haiku machine works fine.

Do you meant haiku system accesed through ssh from non-haiku system? Can you say me more exactly how to reproduce the problem with console vim?

by eanyx, 10 years ago

patch to fix less and more problem ticket #4361

comment:16 by eanyx, 10 years ago

patch: 01

comment:17 by mmu_man, 10 years ago

As korli mentionned 4 years ago it's actually a workaround and doesn't fix the actual problem. more definitely prints something, it just doesn't wait for input and clears the screen immediately.

comment:18 by mmu_man, 10 years ago

For the record, here is what both give in Debugger:

~> hd more.out.txt 
00000000   1b 5b 3f 31 30 34 39 68  1b 5b 3f 31 68 1b 3d 0a   .[?1049h.[?1h.=. 
00000010   75 73 65 72 3a 78 3a 30  3a 30 3a 59 6f 75 72 73   user:x:0:0:Yours 
00000020   65 6c 66 3a 2f 62 6f 6f  74 2f 68 6f 6d 65 3a 2f   elf:/boot/home:/ 
00000030   62 69 6e 2f 62 61 73 68  0a 0a 1b 5b 4b 1b 5b 3f   bin/bash...[K.[? 
00000040   31 6c 1b 3e 1b 5b 3f 31  30 34 39 6c 20 20 20 20   1l.>.[?1049l.... 

~> hd less.out.txt 
00000000   1b 5b 3f 31 30 34 39 68  1b 5b 3f 31 68 1b 3d 0a   .[?1049h.[?1h.=. 
00000010   75 73 65 72 3a 78 3a 30  3a 30 3a 59 6f 75 72 73   user:x:0:0:Yours 
00000020   65 6c 66 3a 2f 62 6f 6f  74 2f 68 6f 6d 65 3a 2f   elf:/boot/home:/ 
00000030   62 69 6e 2f 62 61 73 68  0a 1b 5b 37 6d 2f 65 74   bin/bash..[7m/et 
00000040   63 2f 70 61 73 73 77 64  20 28 45 4e 44 29 1b 5b   c/passwd.(END).[ 
00000050   32 37 6d 1b 5b 4b 0a 0a  0a 0a 1b 5b 4b 1b 5b 3f   27m.[K.....[K.[? 
00000060   31 6c 1b 3e 1b 5b 3f 31  30 34 39 6c 0a 0a 20 20   1l.>.[?1049l.... 

comment:19 by mmu_man, 10 years ago

Odd, doing an ssh to a linux box, more works as expected in Terminal, but copying the linux xterm terminfo file to ~/.terminfo/x/ doesn't work though.

comment:20 by waddlesplash, 10 years ago

patch: 10

comment:21 by axeld, 8 years ago

Owner: changed from axeld to nobody
Status: newassigned

comment:22 by pulkomandy, 5 years ago

Can't reproduce, is this fixed?

comment:23 by dogcow, 4 years ago

I am unable to reproduce this on R1/beta2. less and more generate the expected output on both single-line and multi-line files.

comment:24 by waddlesplash, 4 years ago

Resolution: not reproducible
Status: assignedclosed

comment:25 by pulkomandy, 4 years ago

Milestone: R1R1/beta2
Note: See TracTickets for help on using tickets.