Opened 11 years ago

Last modified 2 years ago

#2514 assigned bug

Enlarged Terminal wraps input line overwriting beginning

Reported by: stippi Owned by: nobody
Priority: normal Milestone: R1
Component: Applications/Command Line Tools Version: R1/pre-alpha1
Keywords: Cc: adek336@…
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Make the Terminal wider and enter a longer command line. Before you get to the right end of the window, the cursor will be replaced to the beginning of the line overwriting what you already wrote. Maybe the wrap-around happens at about the position of the original Terminal width.

Attachments (1)

screen1.png (122.6 KB) - added by scottmc 11 years ago.
long lines in terminal aren't always displayed correctly

Download all attachments as: .zip

Change History (20)

comment:1 Changed 11 years ago by bonefish

Component: Applications/Terminal- General
Owner: changed from jackburton to axeld

Can't reproduce the bug according to your description. I can reproduce it though, when the Terminal window is resized while a program other than the shell is running in the foreground (less, vim,...). After terminating the program the described behavior can be observed. Apparently bash/readline doesn't re-get the terminal window size for some reason. Might be a bug in the bash/readline version we're using or just in the Haiku port.

Changed 11 years ago by scottmc

Attachment: screen1.png added

long lines in terminal aren't always displayed correctly

comment:2 Changed 11 years ago by scottmc

This can also be seen if you type really long commands and then recall them later by using the cursor up/down keys. See attached screenshot. Note that the command should read:

./configure --prefix=/boot/common LDFLAGS=-L/boot/common/lib CPPFLAGS=-I/boot/common/include

as is actually executed as it should be, just that it's being displayed wrong. This is on hrev26990.

comment:3 Changed 11 years ago by Adek336

Cc: adek336@… added

comment:4 Changed 10 years ago by Adek336

src/bin/bash/lib/readline/terminal.c: function _rl_get_screen_size() is called (probably from a SIGWINCH handler) upon terminal resize when no command is being executed. Upon terminal resizing, neither when a command is being executed nor after returning from it, does _rl_get_screen_size() get called; and thus the dimensions aren't updated.

The first take at the problem is to update screen size after returning from a command, there's probably a better way though.

Index: src/bin/bash/eval.c
===================================================================
--- src/bin/bash/eval.c (revision 28658)
+++ src/bin/bash/eval.c (working copy)
@@ -140,7 +140,8 @@
 
              executing = 1;
              stdin_redir = 0;
              execute_command (current_command);
+             rl_resize_terminal();
 
            exec_done:
              if (current_command)

comment:5 Changed 10 years ago by Adek336

Why is vendor/bash/current is of version 3.2 while trunk/src/bin/bash contains the 2.05b version?

comment:6 in reply to:  5 Changed 10 years ago by korli

Replying to Adek336:

Why is vendor/bash/current is of version 3.2 while trunk/src/bin/bash contains the 2.05b version?

There is a hope to get the mainstream bash running on Haiku :)

comment:7 Changed 10 years ago by Adek336

The version in trunk/bin isn't the mainstream one?

---

lib/sh/Makefile and lib/tilde/Makefile reference /Dano/home/obos/... which prevent bash from compiling on Linux (compiles on Linux when changed to ../..).

comment:8 Changed 10 years ago by Adek336

I found the proper solution.

The file ~/.bashrc must contain the line

shopt -s checkwinsize

Also under a linux install, you will notice that removing this line from ~/.bashrc enables one to reproduce the bug under linux.

comment:9 Changed 10 years ago by Adek336

Um, Bash on Haiku doesn't seem to pick up the ~/.bashrc file, so you have to enter the command manually to a running bash, that helps.

comment:10 Changed 10 years ago by Adek336

~/.bashrc is picked up after all, just not by the login shell.

You have to append that shopt line to both /etc/profile for login shells and ~/.bashrc for non login shells.

comment:11 Changed 10 years ago by Adek336

Currently bash will ignore /etc/bashrc and /etc/bash.bashrc, perhaps shopt -s checkwinsize should be written in one of these two, as a generally useful option, while ~/.bashrc would be left empty for custom user use.

comment:12 Changed 10 years ago by axeld

Resolution: fixed
Status: newclosed

Fixed in hrev28772, thanks! It's now in /etc/profile only (and therefore would be used by other shells as well - /etc/bashrc would be the preferred location).

comment:13 Changed 10 years ago by Adek336

Currently, running a second bash from the terminal by typing bash<enter> invokes a non-login shell which ignores /etc/profile (which is sourced only by login shells). So, for example, "ls" is colorful in a login shell, but in a non-login shell.

The following makes non-login shells source /etc/bashrc:

Index: src/bin/bash/config-top.h
===================================================================
--- src/bin/bash/config-top.h   (wersja 28736)
+++ src/bin/bash/config-top.h   (kopia robocza)
@@ -73,7 +73,7 @@
 #define KSH_COMPATIBLE_SELECT

 /* System-wide .bashrc file for interactive shells. */
-/* #define SYS_BASHRC "/etc/bash.bashrc" */
+#define SYS_BASHRC "/etc/bashrc"

 /* System-wide .bash_logout for login shells. */
 /* #define SYS_BASH_LOGOUT "/etc/bash.bash_logout" */

After this, one can move the general parts of /etc/profile to /etc/bashrc (that is, everything from alias ls=... down to shopt -s checkwinsize) and add the line

source /etc/bashrc

to /etc/profile.

comment:14 Changed 10 years ago by Adek336

But other shells still see the bashrc specific command "source /etc/bashrc" in /etc/profile.
So bash should load not only /etc/profile but also /etc/bash_profile (which would consist only of "source /etc/bashrc") for login shells.

comment:15 Changed 10 years ago by Adek336

comment:16 Changed 10 years ago by Adek336

Resolution: fixed
Status: closedreopened

ping ! that patch divides the profile code into general and bash-specific. It only needs a change to the build system so that the new files are copied to /etc.

comment:17 Changed 10 years ago by axeld

I'm not really fond of that solution, it's a bit too invasive and unnecessary IMO. AFAICT our current /etc/profile is pretty much POSIX shell conformant, so other shells shouldn't have a problem with it. Either way, Haiku comes with bash, and there won't be another shell. If a user wants to install his own shell, it's his problem.

Why not just enable /etc/bashrc, and put the shopt in both of them?

comment:18 Changed 8 years ago by diver

Component: - GeneralApplications/Command Line Tools

comment:19 Changed 2 years ago by axeld

Owner: changed from axeld to nobody
Status: reopenedassigned
Note: See TracTickets for help on using tickets.