Executable Octave script: odd behavior when called with option ‘-display’

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Executable Octave script: odd behavior when called with option ‘-display’

Bernd Lütkenhöner

Hi


Trying to call an executable Octave script with the option -display I found an odd behavior. This behavior can already be found in the trivial script ‘hello’:

#! /usr/bin/octave -qf
disp('Hello world');

Calling this script as
./hello
./hello -disp xyz
./hello -display

yields, as expected, the output ‘Hello world’. However, no output appears if I call the script as
./hello -display xyz
I could easily avoid the problem by changing, in my software, the name of the option (e.g. ‘disp’ instead of ‘display’). However, I am curious to understand what goes wrong.

My Octave version is 4.2.2 (running under Ubuntu).


---
Bernd


Reply | Threaded
Open this post in threaded view
|

Re: Executable Octave script: odd behavior when called with option ‘-display’

siko1056
On Fri, Sep 14, 2018 at 10:31 PM Bernd Lütkenhöner <[hidden email]> wrote:

Hi


Trying to call an executable Octave script with the option -display I found an odd behavior. This behavior can already be found in the trivial script ‘hello’:

#! /usr/bin/octave -qf
disp('Hello world');

Calling this script as
./hello
./hello -disp xyz
./hello -display

yields, as expected, the output ‘Hello world’. However, no output appears if I call the script as
./hello -display xyz
I could easily avoid the problem by changing, in my software, the name of the option (e.g. ‘disp’ instead of ‘display’). However, I am curious to understand what goes wrong.

My Octave version is 4.2.2 (running under Ubuntu).


---
Bernd


Dear Bernd,

What do you expect to happen when you call "./hello" with the "-disp" or "-display" argument?  At least both are not Octave command line arguments [1], thus I cannot say which program interprets them.  Maybe you take a close look at how to run proper Octave M-Files from command line.  For a script "hello.m" only containing the "disp('Hello world');" line you can call

/user/bin/octave -qf hello.m

HTH,
Kai



Reply | Threaded
Open this post in threaded view
|

Re: Executable Octave script: odd behavior when called with option ‘-display’

Bernd Lütkenhöner
Hello Kai,

My real software is, of course, much more complicated (with thousands of lines
of code, mainly developed under MATLAB). The idea is to call this software from
an executable Octave script as:

   mySoftware(argv())

The function 'mySoftware' then interpretes argv. Everything works fine, except
for the case that the Octave script is called with the option '-display xyz'.
Therefore I stripped down my software until I finally found out that the problem
already arises in the trivial script 'hello' (see my originally posting).
Calling my script 'hello' with options (whatever they are) should have no effect
at all. However, the option '-display xyz' suppresses the output 'Hello world'.
This is quite odd in my opinion.

Kind regards
Bernd



Am 15.09.2018 um 17:59 schrieb Kai Torben Ohlhus:

> On Fri, Sep 14, 2018 at 10:31 PM Bernd Lütkenhöner <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi
>
>
>     Trying to call an executable Octave script with the option -display I found
>     an odd behavior. This behavior can already be found in the trivial script
>     ‘hello’:
>
>     #! /usr/bin/octave -qf
>     disp('Hello world');
>
>
>     Calling this script as
>
>     ./hello
>     ./hello -disp xyz
>     ./hello -display
>
>
>     yields, as expected, the output ‘Hello world’. However, no output appears if
>     I call the script as
>
>     ./hello -display xyz
>
>     I could easily avoid the problem by changing, in my software, the name of
>     the option (e.g. ‘disp’ instead of ‘display’). However, I am curious to
>     understand what goes wrong.
>
>     My Octave version is 4.2.2 (running under Ubuntu).
>
>
>     ---
>     Bernd
>
>
> Dear Bernd,
>
> What do you expect to happen when you call "./hello" with the "-disp" or
> "-display" argument?  At least both are not Octave command line arguments [1],
> thus I cannot say which program interprets them.  Maybe you take a close look at
> how to run proper Octave M-Files from command line.  For a script "hello.m" only
> containing the "disp('Hello world');" line you can call
>
> /user/bin/octave -qf hello.m
>
> HTH,
> Kai
>
> [1]: https://octave.org/doc/v4.2.2/Command-Line-Options.html



Reply | Threaded
Open this post in threaded view
|

Re: Executable Octave script: odd behavior when called with option ‘-display’

Mike Miller-4
In reply to this post by Bernd Lütkenhöner
On Fri, Sep 14, 2018 at 20:47:16 +0200, Bernd Lütkenhöner wrote:
> However, no output appears if
> I call the script as
>
> ./hello -display xyz

Octave is a Qt application. As such, certain options are handled by Qt,
for example -display, -geometry, -platform, -reverse, -session, and
-style.

So the above is interpreted as a standard Qt -display option, with the
same meaning as setting the DISPLAY environment variable. Since a
display named 'xyz' can't be opened, it looks like Octave silently
refuses to start.

--
mike



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Executable Octave script: odd behavior when called with option ‘-display’

Bernd Lütkenhöner
Am 15.09.2018 um 19:01 schrieb Mike Miller:

> On Fri, Sep 14, 2018 at 20:47:16 +0200, Bernd Lütkenhöner wrote:
>> However, no output appears if
>> I call the script as
>>
>> ./hello -display xyz
>
> Octave is a Qt application. As such, certain options are handled by Qt,
> for example -display, -geometry, -platform, -reverse, -session, and
> -style.
>
> So the above is interpreted as a standard Qt -display option, with the
> same meaning as setting the DISPLAY environment variable. Since a
> display named 'xyz' can't be opened, it looks like Octave silently
> refuses to start.
>

This makes sense. Thank you for your explanation, Mike. I will simple avoid the
problem by naming my option '-disp'.

Bernd