Bug 572291

Summary: [PATCH] read in a ksh script in utf-8 locale does not restore tty settings
Product: [Fedora] Fedora Reporter: Siddhesh Poyarekar <spoyarek>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: mfranc, mhlavink, mnewsome
Target Milestone: ---Keywords: EasyFix, Patch, Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 573936 (view as bug list) Environment:
Last Closed: 2011-10-04 11:35:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
cook tty if operating in a multibyte environment (utf-8) none

Description Siddhesh Poyarekar 2010-03-10 18:58:00 UTC
Created attachment 399158 [details]
cook tty if operating in a multibyte environment (utf-8)

Description of problem:
When a read command is run in a ksh script and is allowed to time out, ksh fails to restore the tty settings. Due to this the terminal stops echoing characters anymore until it is reset. This happens only when the locale is set to something with utf-8 encoding (en_US.UTF-8 for example)

Version-Release number of selected component (if applicable):
ksh-20100309-1.fc14.x86_64

How reproducible:
Always

Steps to Reproduce:
Run the following script and wait for it to return:

##############################
#!/bin/ksh
TMOUT=5
read
##############################

Actual results:
Script returns after 5 seconds and the terminal no longer echoes key strokes

Expected results:
Script returns after 5 seconds and the terminal behaves normally

Additional info:
When running in a UTF-8 locale, ksh employs viraw mode to accept input, due to which the tty is made into a raw terminal with echo disabled. It does not however, restore the terminal on exit, leading to a tty which does not echo keystrokes. Attached patch fixes this.

Comment 1 Michal Hlavinka 2010-03-11 10:35:27 UTC
I can reproduce this, but attached patch does not fix the problem for me.

I'll forward this issue to upstream

Comment 2 Siddhesh Poyarekar 2010-03-11 11:21:46 UTC
That's odd, I had tested this on rawhide. Can you try this scratch build; it's for x86_64:

https://koji.fedoraproject.org/koji/taskinfo?taskID=2044973

-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers

Comment 3 Michal Hlavinka 2010-03-11 13:42:36 UTC
oops, I've updated wrong ksh package. I can confirm the patch fixes this bug

Comment 4 Michal Hlavinka 2010-03-26 13:58:58 UTC
fixed since: ksh-20100309-2.fc14 (and also F13,F12,F11)

Comment 5 Siddhesh Poyarekar 2010-03-26 18:02:30 UTC
The fix is incorrect and does not work. It should not be:

sh_isoption(mbwide()||SH_EMACS)

It should be:

mbwide()||sh_isoption(SH_EMACS)

Can we reopen this or do I need to file another bug?

-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers

Comment 6 Michal Hlavinka 2010-03-29 06:21:45 UTC
oops, my bad... will fix it now

thanks for catching this

Comment 7 Michal Hlavinka 2010-03-29 06:43:48 UTC
fixed since: ksh-20100309-3.fc14 (and also F13,F12,F11)

Comment 8 Fedora Update System 2010-03-30 09:09:09 UTC
ksh-20100309-3.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/ksh-20100309-3.fc12

Comment 9 Fedora Update System 2010-03-30 09:09:14 UTC
ksh-20100309-3.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/ksh-20100309-3.fc11

Comment 10 Fedora Update System 2010-03-30 09:09:18 UTC
ksh-20100309-3.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/ksh-20100309-3.fc13

Comment 11 Fedora Update System 2010-04-20 13:06:06 UTC
ksh-20100309-3.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 12 Fedora Update System 2010-04-20 13:15:44 UTC
ksh-20100309-3.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2010-04-20 13:25:49 UTC
ksh-20100309-3.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 Miroslav Franc 2011-08-24 10:31:49 UTC
this is still broken in ksh for the following reproducer:

##############################
#!/bin/ksh -i
TMOUT=5
read
##############################


Tested on: (locale en_US.UTF-8)
ksh-20110630-2.fc17.x86_64
ksh-20110505-2.fc15.x86_64