bugGNU Octave - Bugs: bug #40537, save() work incorrectly when...

 
 

bug #40537: save() work incorrectly when filename contain square brackets pair []

Submitted by:  count <count>
Submitted on:  Sun 10 Nov 2013 03:37:26 PM UTC  
 
Category: Octave FunctionSeverity: 2 - Minor
Priority: 5 - NormalItem Group: Incorrect Result
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 01 Dec 2016 06:00:07 AM UTC, comment #4:

A fix is simple, like the attached file.

The problem is as pointed out in comment #1 that this behavior is intended:

libinterp/corefcn/load-save.cc

But I would argue that in MATLAB, save('a') will simply save all variables to a file named "a.mat", without a warning.

(file #39124)

count <count>
Wed 23 Nov 2016 09:29:16 PM UTC, comment #3:

This behavior is still present in Octave 4.2.0.

Hartmut <hardy>
Mon 11 Nov 2013 08:26:09 AM UTC, comment #2:

In this case

I think we should save all variables to the file "ab*", since the document say

It's the first form of this command.
The first non-option string is always a filename.

Well, yes, "ab*" is a bed name although.... or maybe make it a warning instead of error?

count <count>
Sun 10 Nov 2013 03:55:10 PM UTC, comment #1:

Confirmed on the development version.

Many programs are going to have trouble with file names containing square brackets, it's best to stick to portable file names.

That being said, your analysis looks right, the save function is interpreting the file name as a variable pattern because it looks like a glob string. The same error occurs if you try to save to a file containing an asterisk or a question mark.

There is a comment in the code that suggests this is done intentionally. Probably to prevent users from calling save with a pattern and no file name.

So if a user runs

should it save all variables to a file named "ab*", or should it error like it does today because that is probably not what they meant?

Mike Miller <mtmiller>
Project Administrator
Sun 10 Nov 2013 03:37:26 PM UTC, original submission:

octave tell me "error: Invalid call to save." etc when I run

The expected result is saving all variables into the file named "a[s]"
Problem also exist in version 3.6.2 and 3.4.3

Seems that it's relate to the wildcard patterns [ list ] match function in save().

Luckily, this works:

count <count>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #39124:  fix_bug40537_v1.cset added by count (1022B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by count (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 01 Dec 2016 06:00:07 AM UTCcountAttached File-=>Added fix_bug40537_v1.cset, #39124
    Sun 10 Nov 2013 03:55:10 PM UTCmtmillerSeverity3 - Normal=>2 - Minor
      StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1