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

Terminal does not display command after go-prompt exit #228

Open
mrpre opened this issue Apr 9, 2021 · 7 comments · Fixed by gregoo/go-prompt#1 or influxdata/go-prompt#1 · May be fixed by #239 or #263
Open

Terminal does not display command after go-prompt exit #228

mrpre opened this issue Apr 9, 2021 · 7 comments · Fixed by gregoo/go-prompt#1 or influxdata/go-prompt#1 · May be fixed by #239 or #263
Labels

Comments

@mrpre
Copy link

mrpre commented Apr 9, 2021

Bug reports

After go-prompt exit the BASH doesn't show what I have inputed.

It's All ok when go-prompt doesn't been run.

input: date + enter

[root /ctl]
$date
Fri Apr  9 11:49:41 CST 2021
[root /ctl]
$./ctl ops
>>> exit
Bye!

After go-prompt run, command date I have input missed.

input: date + enter

[root /ctl]
$Fri Apr  9 11:49:48 CST 2021

command reset make terminal return normal.

@mrpre mrpre added the bug label Apr 9, 2021
@dshelley66
Copy link

I noticed the same thing - I think it is due to the pkg/term upgrade in v0.2.6 - downgrading to v0.2.5 seems to avoid this issue.

@nodauf
Copy link

nodauf commented Apr 15, 2021

for those you have the same issue. I did a workaround with the following code

func handleExit() {
	rawModeOff := exec.Command("/bin/stty", "-raw", "echo")
	rawModeOff.Stdin = os.Stdin
	_ = rawModeOff.Run()
	rawModeOff.Wait()
}

func main(){
	defer handleExit()
....
}

@Neofish22
Copy link

Confirm @nodauf's solution works nicely. I believe stty sane is also a valid choice here.

Xiami2012 pushed a commit to Xiami2012/go-prompt that referenced this issue Jun 17, 2021
This bug is introduced by 20e0658.
Saving a *unix.Termios and then modifying it in SetRaw() makes the
saved state useless.

By restoring saveTermios type from *unix.Termios to unix.Termios,
SetRaw() no longer influences the saved termios.

This should fix c-bata#228 and c-bata#233 .

Signed-off-by: Xiami <i@f2light.com>
Xiami2012 pushed a commit to Xiami2012/go-prompt that referenced this issue Jun 17, 2021
This bug is introduced by 20e0658.
Saving a *unix.Termios and then modifying it in SetRaw() makes the
saved state useless.

By restoring saveTermios type from *unix.Termios to unix.Termios,
SetRaw() no longer influences the saved termios.

This should fix c-bata#228 and c-bata#233 .

Signed-off-by: Xiami <i@f2light.com>
@Xiami2012 Xiami2012 linked a pull request Jun 17, 2021 that will close this issue
youkaicountry added a commit to koinos/koinos-cli that referenced this issue Jul 12, 2021
@hellojukay
Copy link

reset command can restore the tty attribution

LeonidVas added a commit to tarantool/tt that referenced this issue Apr 18, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).

Part of #15
LeonidVas added a commit to tarantool/tt that referenced this issue Apr 18, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).

Part of #15
LeonidVas added a commit to tarantool/tt that referenced this issue Apr 19, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).

Part of #15
LeonidVas added a commit to tarantool/tt that referenced this issue Apr 20, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).

Part of #15
LeonidVas added a commit to tarantool/tt that referenced this issue Apr 20, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).

Part of #15
LeonidVas added a commit to tarantool/tt that referenced this issue Apr 20, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).

Part of #15
LeonidVas added a commit to tarantool/cartridge-cli that referenced this issue Apr 20, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).
LeonidVas added a commit to tarantool/cartridge-cli that referenced this issue Apr 20, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).
LeonidVas added a commit to tarantool/cartridge-cli that referenced this issue Apr 21, 2022
The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(c-bata/go-prompt#228).
@elyscape
Copy link

This happens because getOriginalTermios() returns a pointer to the original unix.Termios struct, and then SetRaw() modifies it. This can be fixed by changing getOriginalTermios() to copy saveTermios into a new struct and returning that:

func getOriginalTermios(fd int) (unix.Termios, error) {
	var err error
	saveTermiosOnce.Do(func() {
		saveTermiosFD = fd
		saveTermios, err = termios.Tcgetattr(uintptr(fd))
	})
	return *saveTermios, err
}

SetRaw() and Restore() would then need to be adjusted to pass a pointer to the variable they pass into termios.Tcsetattr().

@elyscape
Copy link

Incidentally, the reason this broke in v0.2.6 is that this was the version that changed getOriginalTermios() to return a pointer instead of a copied struct.

elyscape added a commit to elyscape/go-prompt that referenced this issue Sep 10, 2022
@bluzarraga
Copy link

@c-bata Is there any timeline for implementing this fix? I see there is a pr linked here and a similar one to address the same issue from June 2021 #239. I am also experiencing this issue consistently.

better0fdead added a commit to tarantool/tt that referenced this issue Apr 27, 2023
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
better0fdead added a commit to tarantool/tt that referenced this issue Apr 28, 2023
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
better0fdead added a commit to tarantool/tt that referenced this issue Apr 28, 2023
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
better0fdead added a commit to tarantool/tt that referenced this issue Apr 28, 2023
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
better0fdead added a commit to tarantool/tt that referenced this issue Apr 28, 2023
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
psergee pushed a commit to tarantool/tt that referenced this issue May 2, 2023
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
nanjj added a commit to nanjj/openGemini that referenced this issue Mar 8, 2024
The patch workaround issue [c-bata/go-prompt#228], make the terminal running
ts-cli works correctly after quit, exit, ControlC or ControlD.

Signed-off-by: JUN JIE NAN <nanjunjie@gmail.com>
nanjj added a commit to nanjj/openGemini that referenced this issue Mar 8, 2024
The patch workaround issue [c-bata/go-prompt#228], make the terminal running
ts-cli works correctly after quit, exit, ControlC or ControlD.

Signed-off-by: JUN JIE NAN <nanjunjie@gmail.com>
nanjj added a commit to nanjj/openGemini that referenced this issue Mar 20, 2024
The patch workaround issue [c-bata/go-prompt#228], make the terminal running
ts-cli works correctly after quit, exit, ControlC or ControlD.

Signed-off-by: JUN JIE NAN <nanjunjie@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment