Closed smalltalkman closed 4 months ago
I think that's the normal behaviour, isn't it?
bash, dash and ksh on Linux all do the same thing.
I think that's the normal behaviour, isn't it?
bash, dash and ksh on Linux all do the same thing.
Ah yes, I overlooked that. I should compare with the linux results, not with msys2.
Oh, maybe that's the real question:
D:\gym\softwares\busybox>busybox_pre64.exe sh -l
C:/Users/lenovo #
C:/Users/lenovo # cd ~
~ #
~ # cat test.txt
line1
line2
line3~ # ls -l
total 4
-rw-rw-r-- 1 root root 17 Apr 08 17:28 test.txt
~ #
~ # cat test.txt
line1
line2
~ # cat test.txt
When I use the up and down arrows to turn pages after executing the cat test.txt
command for the second time, the last line disappears.
Yes, the BusyBox line editing code isn't as clever as that used by other shells. This isn't unique to busybox-w32, the same problem is apparent in upstream BusyBox on Linux.
As a workaround, and typically also convenient regardless, you could change the shell prompt to begin with a newline, so that it normally follows an empty line (this makes it easier to identify where a command ends and the next prompt starts), and, in the case where the program doesn't print a final newline, like your cat test
, at least the prompt begins at the leftmost of the screen:
export PS1='\n\w \$ '
Or, if you feel bold, 3-lines prompt, maybe somethig like this (newline, bold yellow working directry, blue time, reset color, newline, prompt):
export PS1='\n\e[1;33m\w \e[34m\t\e[m\n\$ '
Check the bash manual on what you can put in PS1
(and other prompts), and this page for terminal colors.
@avih Thank you so much! It works very well.
export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
You're welcome.
when
cat
file without newline at end, shell does not wrap.