Bug 361047

Summary: UI::RunInTerminal not available from commandline mode.
Product: [openSUSE] openSUSE 11.0 Reporter: Benjamin Weber <benji>
Component: YaST2Assignee: Katarina Machalkova <kmachalkova>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None    
Version: Alpha 2   
Target Milestone: Alpha 2   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Test Case
Patch for testcase in comment #1

Description Benjamin Weber 2008-02-12 11:21:35 UTC
A call to UI::RunInTerminal from command line mode results in:

[ui] YUI_builtins.cc(runInTerminal):258 Not in text-mode: Cannot run external program in terminal.

It should be possible to run commands in the terminal from the command line mode.

Use Case: http://blogs.warwick.ac.uk/bweber/entry/installing_using_one/ which at the moment requires a wrapper shell script.

TestCase attached, sample usage: 

/sbin/YaST2 ./CLRunInTerminalTestCase.ycp runtest command="echo hello"
Comment 1 Benjamin Weber 2008-02-12 11:22:08 UTC
Created attachment 194424 [details]
Test Case
Comment 2 Katarina Machalkova 2008-02-12 15:07:07 UTC
From IRC:

(12:40:01)  bubli:  benJIman: Strange, it 'somehow' works for me ... but you have to run '/sbin/yast', not '/sbin/YaST2' 
(12:40:36)  benJIman:  bubli: Well then it'll be using ncurses instead of Qt which might help. 
(12:40:36)  bubli:  as 'YaST2' tries to initialize GUI, which does not implement RunInTerminal builtin 
(12:41:30)  bubli:  But yet, the return value of system("echo hello") is 256, which is weird

RunInTerminal builtin uses system() to execute interactive command, which runs '/bin/sh -c echo hello'. It means that 'echo hello' returned 1 for some reason. Let me try strace ...
Comment 3 Katarina Machalkova 2008-02-12 16:36:09 UTC
yast2-ncurses in openSUSE 10.3 does not implement file descriptor saving and restoring, it has been introduced later with enabled thread support in 11.0 (in fact, the code is there in 10.3 already, check for 'FIXME: enable these with thread support' comments, but it is commented out) 

Yast grabs stdout and stderr for itself and redirects it to y2log, so even if it leaves ncurses mode in UI::RunInTerminal temporarily, it still holds stdout and stderr. Newly launched ncurses app (e.g. shell) cannot write to terminal and exits with the above strange error code. 

This is already fixed in yast2-ncurses 2.16.10



Comment 4 Katarina Machalkova 2008-02-12 16:39:09 UTC
Created attachment 194502 [details]
Patch for testcase in comment #1

The commandline code is missing "guihandler". No clue what it is ;-) but it needs to be present to make CommandLine module happy. It may be just some dummy function returning YCP symbol (as in this case)
Comment 5 Katarina Machalkova 2008-02-13 12:45:48 UTC
I suppose we can close this one as fixed. Not for 10.3, but certainly for 11.0