bugGNU Octave - Bugs: bug #43426, run doesn't return to original...

 
 

bug #43426: run doesn't return to original working directory if using relative path

Submitted by:  Andreas Weber <andy1978>
Submitted on:  Thu 16 Oct 2014 11:47:55 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

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 Jump to the original submission)

Mon 27 Oct 2014 04:16:35 AM UTC, comment #8:

I checked in a fix here (http://hg.savannah.gnu.org/hgweb/octave/rev/a834b3151c7e). Instead of creating a third variable holding a directory name I used canonicalize_file_name() to make the relative directory name into an absolute one. With this in place strcmp to pwd works because pwd() also returns an absolute name.

I also renamed the original directory startdir instead of wd to be a little clearer.

Rik <rik5>
Project Administrator
Sat 18 Oct 2014 06:49:18 PM UTC, comment #7:

bc_pwd was b(efore)c(all to script)_pwd. Sorry, I'm not good at creating meaningfull var names :-). script_directory is much better.

Andreas Weber <andy1978>
Project Member
Sat 18 Oct 2014 05:45:14 PM UTC, comment #6:

Ok. I understand now.

What does the "bc_pwd" mean? Should we use something more clear? Something like "script_directory" or something else?

Ben Abbott <bpabbott>
Project Member
Sat 18 Oct 2014 05:00:28 PM UTC, comment #5:

Yes, I try to mimic that Matlab behaviour which you describe in comment #4. Sorry If I was unclear.

When run("dir1/file.m") is called, the working directory is changed to dir1 before file.m gets executed.

If the script called with run doesn't change the working directory (pwd before and pwd after call of script are equal) then the working directory previous to run should be restored.

I've attached another test case to show this better. The first and second output should show the path where show_runbug.m resides in, the third should show your home dir.

(Btw, I accidentally left "keyboard" in the pasted code snippet :-D )

Andreas Weber <andy1978>
Project Member
Sat 18 Oct 2014 04:20:58 PM UTC, comment #4:

Ok. I understand your point, but it appears that Matlab returns to the original working directory.

Ben Abbott <bpabbott>
Project Member
Sat 18 Oct 2014 03:46:23 PM UTC, comment #3:

I think this won't work. The idea is to check if the called script (line 66) has changed the current working dir and only return to the old pwd (=wd) is not.

I would suggest

Andreas Weber <andy1978>
Project Member
Sat 18 Oct 2014 03:32:35 PM UTC, comment #2:

Proposed change set is attached. Should this be applied to default or gui-release?

(file #32295)

Ben Abbott <bpabbott>
Project Member
Sat 18 Oct 2014 12:30:26 PM UTC, comment #1:

If I understand the intent of the if-block, the fix below should work, correct?

Ben Abbott <bpabbott>
Project Member
Thu 16 Oct 2014 11:47:55 AM UTC, original submission:

Since cset http://hg.savannah.gnu.org/hgweb/octave/rev/1363d909c577 (for bug #41543) run doesn't return back to the original working directory if using a relative path.

See attached archive and run "show_runbug.m" (run('../doit.m')) in octave. The path isn't changed back because there is a comparison

and d is "..". I first thought it would be simple as changing this to

but make_absolute_filename("..") returns a trailing "/" which pwd () doesn't.

Andreas Weber <andy1978>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #32297:  ChangeSet.patch added by bpabbott (900B - application/octet-stream - changeset in Andreas Weber's name)
file #32296:  bug43426.tar.gz added by andy1978 (258B - application/gzip)
file #32295:  changeset.patch added by bpabbott (801B - application/octet-stream)
file #32281:  runbug.tar.gz added by andy1978 (227B - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by bpabbott (Posted a comment)
  • -unavailable- added by andy1978 (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 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 27 Oct 2014 04:16:35 AM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Sat 18 Oct 2014 06:58:11 PM UTCbpabbottAttached File-=>Added ChangeSet.patch, #32297
    Sat 18 Oct 2014 05:01:18 PM UTCandy1978Attached File-=>Added bug43426.tar.gz, #32296
    Sat 18 Oct 2014 03:32:35 PM UTCbpabbottAttached File-=>Added changeset.patch, #32295
      CategoryNone=>Octave Function
      StatusNone=>Patch Submitted
    Thu 16 Oct 2014 11:47:55 AM UTCandy1978Attached File-=>Added runbug.tar.gz, #32281

    Back to the top


    Powered by Savane 3.1-cleanup1