bugGNU Octave - Bugs: bug #60214, Save and Run drops last character...

 
 

bug #60214: Save and Run drops last character of filename for new scripts

Submitted by:  Lars Kindermann <larskindermann>
Submitted on:  Fri 12 Mar 2021 09:12:48 AM UTC  
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  Torsten Lilge <ttl>
Originator Name:  Open/Closed:  Closed
Release:  6.2.0 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Tue 23 Mar 2021 06:07:45 PM UTC, comment #20: 

That cset has it fixed for me, too.

Lars Kindermann <larskindermann>
Tue 23 Mar 2021 04:10:25 PM UTC, comment #19: 

This turned out to be quite the project.  Is it okay to close now?

Rik <rik5>
Project Administrator
Sun 14 Mar 2021 10:02:33 PM UTC, comment #18: 

And finally the cset that consistently disables run (F5) and step (F10) actions depending on the file type:
http://hg.savannah.gnu.org/hgweb/octave/rev/fe06fafb4cac

I have pushed this changeset to the default branch and not to stable branch like the previous csets. This cset fixes a minor issue but the changes are spread over several files and functions with a higher risk of regressions.

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sun 14 Mar 2021 06:34:18 PM UTC, comment #17: 

The possible risk of overwriting a file without warning when using native file dialogs is fixed with cset http://hg.savannah.gnu.org/hgweb/octave/rev/23424aa7a11a

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sun 14 Mar 2021 01:19:38 PM UTC, comment #16: 

Even more strange, it happens only if you open the file twice.

Lars Kindermann <larskindermann>
Sun 14 Mar 2021 01:18:00 PM UTC, comment #15: 

Oh yes, confirmed when opening a file. When using "Save As" for creating such a file, the menu entry is disabled (as it should be).

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sun 14 Mar 2021 01:02:13 PM UTC, comment #14: 

It is enabled if the filname is a valid command + 1 character.

Tr to open with a right click in the files widget...

Lars Kindermann <larskindermann>
Sun 14 Mar 2021 12:54:11 PM UTC, comment #13: 

@Lars: When you open a file without extension, is the menu entry "Run" -> "Save File and Run / Continue" enabled or disabled? It should be disabled (which is the case for me).

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sun 14 Mar 2021 12:49:25 PM UTC, comment #12: 

Changeset http://hg.savannah.gnu.org/hgweb/octave/rev/c24e190ae34f prevents running a new file that was not saved as octave file.

However, another issue showed up when using native file dialogs (Debian/GNOME): When entering a file name without extension, let's say 'foo', an already existing file 'foo.m' is overwritten without warning! Obviously, the file dialog does not consider the automatically appended extension '.m' when checking for the existence of the file to be saved. But it warns if the file without extension 'foo' already exists even though it would not overwrite this file. Non-native file dialogs work well.

Therefore, another patch related for "save files as ..." will follow with a manual warning after the (native) file dialog was closed and the file already exists.

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sun 14 Mar 2021 12:39:28 PM UTC, comment #11: 

The condition to activate "Save and Run" seems inconsistent. If I create a file "helpx" externally and open it in the editor, "Save and Run" is enabled but will execute the "help command".

I suspect the check if a file is executable is done with something like
if filename(1:end-length(extension)-1) is valid_command
assuming there is always a dot in the filename...

Lars Kindermann <larskindermann>
Sun 14 Mar 2021 10:12:35 AM UTC, comment #10: 

Yes, in this case the run part is skipped. But the action "Save File and Run" is disabled if it is not an octave file (flag m_is_octave_file).

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sun 14 Mar 2021 09:40:11 AM UTC, comment #9: 

Run is enabled for files in the editor when the filename(1:end-1) equals a valid command.

Lars Kindermann <larskindermann>
Sun 14 Mar 2021 09:31:28 AM UTC, comment #8: 

Yes, I haven't looked after that yet, because 'Run' is generally disabled for files with no extension or another one than 'm'. But I can confirm: When initiating 'Save and Run' with a new file, save it without extension, the gui still tries to run it and the error occurs. A patch will follow.

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sun 14 Mar 2021 01:34:00 AM UTC, comment #7: 

That fixed it for practical use.

However, the "missing last character" is still lurking somewhere in the code:

Create a textfile named "cde" (without extention), any content, open it in the editor and press f5.

Octave will execute the command "cd".

Lars Kindermann <larskindermann>
Sat 13 Mar 2021 06:34:29 PM UTC, comment #6: 
Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sat 13 Mar 2021 04:31:15 PM UTC, comment #5: 

You are right, there is another issue (at least with the filter signal of the file dialogs in GNOME). I am preparing a patch and will commit this evening.

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Sat 13 Mar 2021 04:24:34 PM UTC, comment #4: 

The bug does not depend on a dot in the path (as shown by pwd). Both the missing .m of the filename and the missing last charater of the command executed in the command window will always happen.

Can you point me to the relevant piece of code so I can try to find the problem on my system, in case it depends on the OS (Debian 11, current testing)?

Lars Kindermann <larskindermann>
Sat 13 Mar 2021 02:18:55 PM UTC, comment #3: 

Lars, thanks for the report. I can confirm the missing .m (on dev and stable), but only when saving the new script into a directory with a '.' in its name. When saving into a directory without '.', the suffiy '.m' is added as expected. Can you confirm this behavior?

If yes, it seems that the cause is QTBUG-59401:
https://bugreports.qt.io/browse/QTBUG-59401

I will try do add a workaround in the GUI.

Torsten Lilge <ttl>
Project MemberIn charge of this item.
Fri 12 Mar 2021 10:38:41 PM UTC, comment #2: 

Makes sense to me to add the '.m' extension.

Rik <rik5>
Project Administrator
Fri 12 Mar 2021 06:16:57 PM UTC, comment #1: 

+1 for automatically adding the .m extension on all platforms. (It's already added automatically on Windows.)

Markus M├╝tzel <mmuetzel>
Project Member
Fri 12 Mar 2021 09:12:48 AM UTC, original submission:  

Start writing a "function foo" in a new editor. Press F5, the editor asks to save the file under the pre-filled name "foo.m" and then executes the command "foo".

Now write a script in a new editor and press F5. When prompted for a name now, the field is empty. So enter "bar".

Result: The file is saved as "bar" (without .m) and the command window attempts to execute "ba" (without the "r"), resulting in an error.

In addition to look for the missing character, I suggest to pre-fill the file select box with ".m" or defaulting to the extention ".m" when saving a new script.

Lars Kindermann <larskindermann>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by larskindermann (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-23 ttl StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2021-03-13 ttl StatusConfirmed => Ready For Test
        Releasedev => 6.2.0
    2021-03-13 ttl Assigned toNone => ttl
    2021-03-12 mmuetzel StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.7