hasanghaforian hasanghaforian - 1 month ago 9
Bash Question

Why octave figure closed very soon in emacs

I use

GNU Emacs 24.3.1
on
Ubuntu 14.04
and I have a simple
octave
script which it's name is
test.m
:

#! /usr/bin/octave -qf
x=1:10
plot(x);


When I try to execute that by
M-! ./test.m
, an empty figure window appears but closed very soon and I saw this result in
emacs
:

warning: function ./test.m shadows a core library function
x=

1 2 3 4 5 6 7 8 9 10


How I can solve this problem?

Answer

The warning is really just that: Your function file test.m shadows the built in function test but as long as you don't want to call the built in test function you can ignore it (although it's considered bad practice to shadow core functions).

The plot disapears because octave exits after running test.m. You have to call Octave with --persist or it's common to add a pause at the end of the script which waits for a keypress:

#! /usr/bin/octave -qf
x=1:10
plot(x);
pause