Re: portable terminal

"John W. Eaton" <[email protected]>
Newsgroups gmane.comp.gnu.octave.maintainers
Message-ID <[email protected]>
On 7/29/20 1:54 PM, Rik wrote:
> On 07/29/2020 09:40 AM, John W. Eaton wrote:
>> On 7/29/20 12:31 PM, Rik wrote:
>>> jwe,
>>>
>>> I saw this bit of code in your latest check-in for __debug_octave__.m:
>>>
>>> +    if (isunix ())
>>> +      ## FIXME: is there a portable way to run a command in a new 
>>> window?
>>> +      ## Obviously, gnome-terminal is not always available.
>>> +      command_string = "gnome-terminal -- gdb -p %d";
>>>
>>> As far as I'm aware there isn't a 100% working solution.  On the 
>>> other hand, it probably is possible to do a bit better than one 
>>> hardcoded terminal.  I happen to use KDE for the desktop and don't 
>>> have said terminal installed.
>>>
>>> I tried xdg-open, but it treats the command as a URL.
>>>
>>> I think for a fair number of systems have the alternatives system 
>>> inherited from Debian (Ubuntu, Mint, etc.) or an implementation 
>>> copied from Debian (RHEL, Fedora) in which case there is a link at 
>>> /usr/bin/x-terminal-emulator which will work.
>>>
>>> Also, can the default be made to use '-e gdb -p %d'?  That syntax 
>>> will work with either gnome-terminal or konsole, but the existing one 
>>> does not.
>>
>> Sure, please make whatever changes are helpful.  I have no objection 
>> to improvements.
> 
> I checked in this change
> 
> diff -r dce34ad6a6ea -r 7bc89d11ec13 scripts/testfun/__debug_octave__.m
> --- a/scripts/testfun/__debug_octave__.m        Wed Jul 29 11:39:52 2020 
> -0400
> +++ b/scripts/testfun/__debug_octave__.m        Wed Jul 29 10:50:07 2020 
> -0700
> @@ -48,14 +48,12 @@ function __debug_octave__ (command_strin
>     endif
> 
>     if (nargin == 0)
> -    [status, ~] = system ("gdb --version");
> +    status = system ("gdb --version");

The reason for calling system with two outputs here was to capture and 
ignore the output from gdb so that detecting it would be silent.  Do we 
really want this check to display the version info to the terminal?

> -      ## FIXME: is there a portable way to run a command in a new window?
> -      ## Obviously, gnome-terminal is not always available.
> -      command_string = "gnome-terminal -- gdb -p %d";
> +      command_string = "x-terminal-emulator -e gdb -p %d";
>       elseif (ispc ())
>         command_string = "start gdb -p %d";
>       elseif (ismac ())
> @@ -65,7 +63,7 @@ function __debug_octave__ (command_strin
>       endif
>     endif
> 
> -  system (sprintf (command_string, getpid ()));
> +  system (sprintf (command_string, getpid ()), "async");
> 
>   endfunction
> 
> It's a bit more generic, but now I've come across a different issue.  I 
> thought passing the "async" option to system() would allow the spawned 
> process to run separately from Octave.  But, at least for me, this 
> stalls Octave
> 
> system ("x-terminal-emulator", "async")
> 
> Is this a new bug, or do I not understand system() correctly?

I think that to use "async", it must be the third argument.  Probably we 
don't need the output from the terminal command, so it would be

   system (sprintf (...), false, "async")

but it seems like the terminal emulator exits after executing the 
program that displays the window anyway, so maybe "async" is not needed, 
at least on Linux systems?  I'm not sure about the others.  Originally, 
I had a separate system command in each branch of the IF command.  I 
don't suppose it hurts to have it.

A separate problem that I see is that when I'm starting Octave from a 
remote system it doesn't open the terminal window.  I'm not sure what's 
happening there.  I have a terminal window open on my desktop system 
running ssh to connect to another system with X forwarding through the 
ssh connection.  My DISPLAY is set properly.  The Octave GUI and Plot 
windows open correctly.  Executing

   system ("emacs", false, "async")

opens a new Emacs window.  But

   system ("x-terminal-emulator", false, "async")

does not.  Weird.

jwe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.