Opened 16 years ago

Closed 5 years ago

Last modified 5 years ago

#2514 closed bug (fixed)

Enlarged Terminal wraps input line overwriting beginning

Reported by: stippi Owned by: nobody
Priority: normal Milestone: R1/beta2
Component: Applications/Command Line Tools Version: R1/pre-alpha1
Keywords: Cc: adek336@…
Blocked By: Blocking:
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 16 years ago.
long lines in terminal aren't always displayed correctly

Download all attachments as: .zip

Change History (22)

comment:1 by bonefish, 16 years ago

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.

by scottmc, 16 years ago

Attachment: screen1.png added

long lines in terminal aren't always displayed correctly

comment:2 by scottmc, 16 years ago

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 by Adek336, 16 years ago

Cc: adek336@… added

comment:4 by Adek336, 16 years ago

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 by Adek336, 16 years ago

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

in reply to:  5 comment:6 by korli, 16 years ago

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 by Adek336, 16 years ago

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 by Adek336, 16 years ago

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 by Adek336, 16 years ago

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 by Adek336, 16 years ago

~/.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 by Adek336, 16 years ago

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 by axeld, 16 years ago

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 by Adek336, 16 years ago

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 by Adek336, 16 years ago

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:16 by Adek336, 16 years ago

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 by axeld, 16 years ago

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 by diver, 14 years ago

Component: - GeneralApplications/Command Line Tools

comment:19 by axeld, 8 years ago

Owner: changed from axeld to nobody
Status: reopenedassigned

comment:20 by pulkomandy, 5 years ago

Resolution: fixed
Status: assignedclosed

According to bash docs, checkwinsize is enabled by default in current versions (https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html). No further change needed here.

comment:21 by nielx, 5 years ago

Milestone: R1R1/beta2

Assign tickets with status=closed and resolution=fixed within the R1/beta2 development window to the R1/beta2 Milestone

Note: See TracTickets for help on using tickets.