You are not logged in.
Hello,
there is a shell script called 'fasd', which, upon calling, shows a temporary text menu with numbered items, and after an item has been selected by pressing a number key, it performs an action and exits.
The problem is that the temporary menu was disappearing from the screen after the program's exit until recently. Now, most likely after a recent system update, it isn't cleared anymore and the text with menu items keeps remaining on the terminal's screen upon the script's exit.
What could have caused such change and how it can be reverted?
bing different
Offline
Which terminal are you using?
Offline
This behaviour is observed in xterm, xfce-terminal and urxvt. (Didn't tested in others.)
bing different
Offline
Hmm.. none of these have been updated recently, so I don't know what caused the change in the behaviour.
Offline
there is a shell script called 'fasd'
Which you will ideally share so that everybody knows what we're dealing with (eg. ncurses or some handwritten junk)
Oh, and cc., you're not on gnome on wayland, are you?
Offline
The DE is XFCE (Xorg). The script is here:
It's a way too advanced to comprehense for my bash knowledge.
bing different
Offline
On a very quick glimpse, it sources config files "/etc/fasdrc" & "$HOME/.fasdrc" and branches zsh; what's your (default) shell, did you change it and if it's zsh - that *was* recently updated.
Offline
As I understand, that script is tuned to work with bash as well as with zsh. I use bash and the script has been working OK and works almost OK now, except for the glitch with remaining temporary output. Maybe some recent or not so recent changes in bash changed the script's behaviour? The script itself has not been updated for a year and a half.
Last edited by nbd (2016-12-30 13:36:42)
bing different
Offline
As I understand, that script is tuned to work with bash as well as with zsh.
Yes, it just makes use of many zsh features (oc. testing whether it can) - and zsh has built-in menu-a-like capabilities, so the script authors focus may be on zsh.
Bash was (really) updated in November last, check your pacman log around the time you noticed the problem first and also try replacing bash with zsh (simply run zsh from bash to see whether that makes a difference)
Offline
I update not often and since November didn't update until several days ago. So maybe November's bash upgrade has caused the changed behaviour. What option can control this behaviour?
The script works as follows. After typing on the command line 'zz' and a part of directory name, the script prints the menu with directory names similar to the parameter and waits for the input with flashing cursor below the menu:
[al ~ ]$ zz tst
4 1.08135 /dir1/tst
3 1.38706 /dir2/tst
2 5.54594 /mnt/dir3/tst
1 78.9584 /mnt/dir4/tst
> _
After pressing a key with a number from the menu, the menu was disappearing and the directory was changed to one selected from the menu. Now the directory changes, but the menu remains on the screen:
[al ~ ]$ zz tst
4 1.08135 /dir1/tst
3 1.38706 /dir2/tst
2 5.54594 /mnt/dir3/tst
1 78.9584 /mnt/dir4/tst
> 1
[al tst]$
Last edited by nbd (2016-12-30 14:32:17)
bing different
Offline
echo of control chars.
1. pin the issue down; downgrade bash and see whether it's still an issue.
2. have you ever tried zsh? ;-)
Offline
I don't have any other shell except bash installed, so I couldn't try zsh. During downgrading bash I got soname bump, since the previous version was linked to a different version of libreadline:
[root@kw al]# pacman -U /home/al/builds/bash-4.3.042-3-x86_64.pkg.tar.xz
loading packages...
warning: downgrading package bash (4.4.005-2 => 4.3.042-3)
resolving dependencies...
looking for conflicting packages...
Package (1) Old Version New Version Net Change
bash 4.4.005-2 4.3.042-3 -0.95 MiB
Total Installed Size: 6.18 MiB
Net Upgrade Size: -0.95 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring [######################################] 100%
(1/1) checking package integrity [######################################] 100%
(1/1) loading package files [######################################] 100%
(1/1) checking for file conflicts [######################################] 100%
(1/1) checking available disk space [######################################] 100%
:: Processing package changes...
(1/1) downgrading bash [######################################] 100%
warning: /etc/bash.bashrc installed as /etc/bash.bashrc.pacnew
/usr/bin/bash: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory
error: command failed to execute correctly
:: Running post-transaction hooks...
(1/1) Updating the info directory file...
/bin/sh: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory
error: command failed to execute correctly
Maybe the new libreadline version has changed something like some time ago new ncurses caused some issues.
Since zsh has bash as a dependency, don't know if it would be a relevant evidence. fasd actually also has customizations for tcsh and posix shells, so zsh doesn't seem like the main intended environment for the script.
bing different
Offline
zsh does *not* depend on bash (where do you get that idea) and I meant to try because what you explained is more or less a stock feature of zsh.
Offline
gdbm is a direct zsh's dependency:
https://www.archlinux.org/packages/core/x86_64/gdbm/
In the readline's changelog there is enormous quantity of differences of 7.0 from 6.3. I wonder, if this can the cause, by chance?:
gg. When refreshing the line as the result of a key sequence, Readline attempts
to redraw only the last line of a multiline prompt.
https://cnswww.cns.cwru.edu/php/chet/readline/CHANGES
Doesn't anyone also uses fasd and observe the same problem? (Judging by github, it's very popular.)
bing different
Offline
nbd, I think it is best if you file this issue on the Github repo itself, you are likely to get better support there.
Offline
And gdbm is bash? ;-P
But the readline change is highly suspicous, yes.
Offline
nbd, I think it is best if you file this issue on the Github repo itself, you are likely to get better support there.
Unfortunately, notwithstanding the high "Starred" number for that repo, the last commented issue there is dated by July. All the more that the question is not so mach about the script, as about bash and libreadline.
Maybe someone familiar with the details of libreadline configuration will give some hint.
bing different
Offline
I'll move this thread to "Applications and DEs" so that it might getter better visibility.
Offline
I'll move this thread to "Applications and DEs" so that it might getter better visibility.
Thanks!
I read in Wiki that zsh doesn't use readline ("Zsh does not use readline, instead it uses its own and more powerful Zsh Line Editor, ZLE. "), so I installed it and the problem persists in zsh as well. Seems that some change happened in some common library used zsh and bash, or in some common library used by all three aforementioned terminals as well as virtual console.
bing different
Offline
some common library used zsh and bash
gcc-libs
glibc
linux-api-headers
Last updates were in August
tzdata
filesystem
iana-etc
Seem unlikely candidates
readline
ncurses
So that leaves just two common elements assuming the required dependencies is accurate and complete.
Did you check if the issues persists if you log directly into a console to eliminate issues related to terminal emulators?
Would also create a new user and check with that to eliminate issues related to config files in the home directory.
Offline
Did 'pacman -Syu', rebooted, logged to the console as another user with almost no configuration files in $HOME, run the script in the virtual console without starting X, and result the same.
Maybe someone knowledgable in shell scripting could take a look at that script to see how the temporary menu which appears on 'zz' alias is programmed and it would be clear why it's not working?
https://github.com/clvv/fasd/blob/master/fasd
'zz' alias is set in the script as:
alias zz='fasd_cd -d -i'
UPDATE:
I tried to read the code and what I don't understand is what caused the temporary menu disappear previously. The script works approximatly as follows.
1. The bash function fasd_cd, takes the arguments and calls the script with them and additionaly with '-e printf %s' parameter which means simply to print the result to stdout on exit. (This function takes one argument which is a shortened (fuzzy) name of a directory to cd into.)
2. Script queries the directory database with the fuzzy directory name and prints the query result, which is a list of full directory names similar to the fuzzy one, as a temporary menu and reads the user's input with a menu item number:
res="$(printf %s\\n "$res" | sort -n${R})"
printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2
printf "> " >&2
local i; read i; [ 0 -lt "${i:-0}" ] 2>> /dev/null || return 1
res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')"
3. It prints the selected line with the full directory name and exits (returns to the bash 'fasd_cd' function).
4. The fasd_cd takes the printed result and executes the 'cd' command with it. The relevant function's code looks as follows:
local _fasd_ret="\$(fasd -e 'printf %s' "\$@")"
[ -d "\$_fasd_ret" ] && cd "\$_fasd_ret"
What shell mechanism caused the menu printed in #2 to be cleared on the 'fasd_cd' exit?
Last edited by nbd (2017-01-02 03:33:05)
bing different
Offline
nbd wrote:some common library used zsh and bash
gcc-libs glibc linux-api-headers
Last updates were in August
tzdata filesystem iana-etc
Seem unlikely candidates
readline ncurses
So that leaves just two common elements assuming the required dependencies is accurate and complete.
I think that this implies that the change was not in libraries used by shells (bash or zsh), but rather in those used by terminals, including the virtual console.
There is a thing in Unix terminals called "alternate display", which causes the program's output to be cleared after it's exit and to restore the previous terminal's screen. This behaviour can be triggered by a command ot terminal sequence:
http://stackoverflow.com/questions/1102 … ash-script
In that script (fasd) I don't see any similar command is called anywhere. So maybe some default settings somewhere were such, that the temporary script's output was cleared after exit, and then maybe some defaults somewhere were changed?
bing different
Offline
zz M<Enter> does *nothing* here (zsh, sometimes - wtf?- it just blocks)
Offline
seth,
1. I presume you are initializing fasd before using it: eval "$(fasd --init auto)" . (It should be done on every shell start. I have this command in .bashrc.)
2. The script creates it's own database file where it writes the names of directories you are opening, so before suggesting the directory names on 'zz' commands it should accumulate some statistics; just cd to several directories.
bing different
Offline
I tried to read the code and what I don't understand is what caused the temporary menu disappear previously. The script works approximatly as follows....
Many terminal emulators support two virtual screens per terminal and a control sequence to switch between them. This has typically been used in the past to have one virtual screen for full-screen-oriented programs such as an editor and another for line-oriented output. The line-oriented output would usually be the default virtual screen - the one the terminal emulator starts with. Functions in a library such as ncurses would send the codes to switch to the other virtual screen on initialisation and switch back on termination.
I am sure I have seen, in the past, some fancy shell configurations where the shell itself uses this feature to separate output from the shell itself from output from the commands run from the shell.
Offline