Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running a previous command with hstr echoes instead of running the command #452

Open
davidhaley opened this issue May 29, 2022 · 15 comments

Comments

@davidhaley
Copy link

davidhaley commented May 29, 2022

I'm not sure what could be causing this.

For example:

echo testing

testing

Then, I press ctrl+r, search for testing, and press enter on the command that we just ran and it echoes:

hstr --

Or, if I use the alias hh, find the previous command and run it:

hh

My config in .bashrc is:

# HSTR configuration - add this to ~/.bashrc
alias hh=hstr                    # hh to be alias for hstr
export HSTR_CONFIG=hicolor       # get more colors
shopt -s histappend              # append new history items to .bash_history
export HISTCONTROL=ignorespace   # leading space hides commands from history
export HISTFILESIZE=10000        # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE}  # increase history size (default is 500)
# ensure synchronization between bash memory and history file
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
# if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hstr -- \C-j"'; fi
# if this is interactive shell, then bind 'kill last command' to Ctrl-x k
if [[ $- =~ .*i.* ]]; then bind '"\C-xk": "\C-a hstr -k \C-j"'; fi

hstr version "2.5.0" (2021-12-13T22:00:00)

@davidhaley davidhaley changed the title "hstr --" Running a previous command with hstr echoes instead of running the command May 29, 2022
@OscarL
Copy link

OscarL commented Oct 9, 2022

Under Haiku we get that same behavior. Upon hitting ENTER after selecting an entry from the history, it gets printed on the console.

Currently using bash version 5.1.16, and hstr 2.5.0 (but it happened too with the original Haiku port of hstr, that was was at version 2.0).

@davidhaley: can you share more info regarding your OS, terminal app, and bash version? Maybe by comparing info, we can start to narrow the search of where the problem might lie.

@OscarL
Copy link

OscarL commented Oct 9, 2022

For the record. The issue on the Haiku port was that it needs to use the same bash function as the CYGWIN port (as Haiku also lacks TIOCSTI):

hstr/src/hstr.c

Line 193 in be59f8c

#elif defined(__CYGWIN__)

And that wasn't reflected on the install/config instructions.

Defining that hstr_cygwin() (I guess it could be called hstr_no_tiocsti() now) bash function and binding it to CTRL+R now works like a charm!

Time to fix/update the Haiku package :-)

@m040601
Copy link

m040601 commented Apr 20, 2023

I'm on Archlinux and I am also having this problem. Maybe related also to , #346 ?

I do remember it was working fine some weeks ? month? ago.

But now, whatever I choose after running "hstr", it always "echoes it", and puts it before the prompt .

It doesnt give me any chance to either,

  • spit it out to the prompt and let me edit it, on the prompt, before entering ENTER and executing
  • spit it out and run it immediately

$ hstr --version

hstr version "3.1.0" (2023-04-18T08:50:00)

Running it says,

RET/TAB select,

the man page itself is not very consistent with this information,

       TAB, RIGHT arrow
              Choose currently selected item for completion and let user to
              edit it on the command prompt.

       ENTER  Choose currently selected item for completion and execute it.

I'v also tried it in different terminals and with zero configurations or customizations on bashrc.

sudo useradd - test_user
su -l test_user

Same problem. Wether I choose "RETURN", "TAB" or "RIGHT", i never get that line of history in the prompt. It always gets printed before the prompt.

Other functionalities like, favourites, deleting etc seems to be working

@vparitskiy
Copy link

vparitskiy commented May 18, 2023

Same problem as above on Manjaro

hstr version "3.1.0" (2023-04-18T08:50:00)

@smahm006
Copy link

smahm006 commented Jul 2, 2023

Must be some kernel thing as It was working for me fine on Debian Sid until I did a kernel upgrade to 6.3.0-1-amd64 and now it echo's but if you type echo !! you notice it doesn't show an echo command.

hstr version "3.1.0" (2023-04-18T08:50:00) as the others

EDIT: Just noticed this has been mentioned in a bigger issue #478 and solution seems to be to run command sysctl -w dev.tty.legacy_tiocsti=1

@silvan-talos
Copy link

@s-mahm solution of running sysctl -w dev.tty.legacy_tiocsti=1 worked for me. Thank you!

@vparitskiy
Copy link

To ensure that this persists across system restarts on distros using recent systemd versions, create new conf file:

sudo sh -c "echo 'dev.tty.legacy_tiocsti=1' > /etc/sysctl.d/9999-legacy-tiocsti.conf"

@Danathar
Copy link

Danathar commented Nov 17, 2023

sysctl -w dev.tty.legacy_tiocsti=1

There is a reason they disabled that. It's a security issue.

https://cateee.net/lkddb/web-lkddb/LEGACY_TIOCSTI.html

So, anybody who wants to disable it, just be aware that there are things in the wild which use that for privilege escalation.

I guess I can live with it just printing instead of allowing me to edit, but that only works on the newest versions of hstr. If you are using an older version that is packaged in Ubuntu or Debian's current stable repositories, you don't even get that. You just get a return to the shell with nothing printed at all.

@plum
Copy link

plum commented Feb 29, 2024

I also get tis on arch, and the @s-mahm solution corrects it.

@smahm006
Copy link

@davidhaley Can you close this issue if it was resolved?

@davidhaley
Copy link
Author

@davidhaley Can you close this issue if it was resolved?

Sorry, I haven't had this installed now for quite some time.

@ElectronicBattle
Copy link

ElectronicBattle commented Aug 20, 2024

It was working on linux mint 21.3 (ubuntu 22.04) but upgrading to LM22 (24.04) causes this problem.

Summarising earlier posts from @leapfog and @vparitskiy (and making them even more clear for people like me, i.e. not very expert in the linux environment!), this is what I did:

sudo sysctl -w dev.tty.legacy_tiocsti=1 and then
sudo sh -c "echo 'dev.tty.legacy_tiocsti=1' > /etc/sysctl.d/9999-legacy-tiocsti.conf"
worked for me too. Maybe the cause was the kernel change associated with my OS upgrade? Current kernel is 6.8.0-40-generic

[edited to reference the earlier posts so that the brain power is correctly ascribed]

@SilkovAlexander
Copy link

It was working on linux mint 21.3 (ubuntu 22.04) but upgrading to LM22 (24.04) causes this problem.

sudo sysctl -w dev.tty.legacy_tiocsti=1 and then sudo sh -c "echo 'dev.tty.legacy_tiocsti=1' > /etc/sysctl.d/9999-legacy-tiocsti.conf" worked for me too. Maybe the cause was the kernel change associated with my OS upgrade? Current kernel is 6.8.0-40-generic

Thank you a lot, that worked for me on Ubuntu 22.04

@Handrail9
Copy link

Handrail9 commented Sep 2, 2024

@davidhaley Can you close this issue if it was resolved?

I don't think the issue was resolved if the solution is turning off a protection against privilege escalation.
@dvorka is there any status update on this issue? I really love this program but I don't feel comfortable with the current solution being proposed here and it's been open for over two years. If it makes any difference I'm not on a Debian or Arched based distro, I'm on Fedora so this seems to affect all three of the big linux base distros.

@X13X
Copy link

X13X commented Nov 20, 2024

So.. a new user here.

Return/Enter does absolutely nothing on a latest install of Ubuntu 22-04

This is a 2 year ongoing issue that is treated like an elephant in the room.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests