bugGNU nano - Bugs: bug #45383, when loading a file into a new...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #45383: when loading a file into a new buffer, errors should not create a new buffer

Submitted by:  Mike Frysinger <vapier>
Submitted on:  Tue 23 Jun 2015 06:23:04 PM UTC  
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  Benno Schulenberg <bens> Open/Closed:  Closed

( Jump to the original submission)

Sat 18 Jul 2015 07:46:22 AM UTC, comment #8: 

Fixed in SVN, r5304.  That is: typing the name of a directory (or something else that is not a normal file) produces just an error message and does not open an empty buffer.  But typing the name of a non-existent file continues to open a new buffer with that name (in multibuffer mode).

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sat 04 Jul 2015 11:23:03 AM UTC, comment #7: 

The second attempt was not good enough by far because it prevented creating new files by specifying their names on the command line.  The third attempt failed to solve also bug #27839.  Attached fourth attempt at a patch should now cover everything.

This does change the current behaviour when specifying a nonexistent file in multibuffer mode: instead of creating an empty buffer with the given name, it will display an error message.  The question is: does anyone intentionally create a new file using ^R in multibuffer mode?  If so, then the second part of the patch should be removed.

(file #34377)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 28 Jun 2015 07:51:18 PM UTC, comment #6: 

Third attempt.  Luckily the parameter 'undoable' appears to coincide with the case where the file is being interactively specified (instead of on the command line or by the linter), because only then must the checks be performed.

(file #34335)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 28 Jun 2015 01:42:44 PM UTC, comment #5: 

Second attempt is attached.  As far as I can tell, this also solves bug #27839.

(file #34333)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 28 Jun 2015 06:52:06 AM UTC, comment #4: 

Proposed patch is not good enough: trying to open directories will leave lock files behind.  Do for example 'src/nano -F README', and type ^R doc <Enter>.  It correctly reports that doc is a directory.  Then type ^R doc <Enter> again, and see how it says the file is already being edited.

It will be necessary to stat the argument, to see whether it exists and is a file, before trying to do anything else with it.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Thu 25 Jun 2015 08:37:29 PM UTC, comment #3: 

The first patch fixes your original bug: trying to load something that isn't a file.  The second patch fixes also my problem: trying to insert a file that doesn't exist.  (Checking for the errno does not seem viable as the actual opening of the file is hidden in a nested function.)

(file #34318, file #34319)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Thu 25 Jun 2015 11:28:29 AM UTC, comment #2: 

if you get an errno that is not ENOENT, it should only show an error and not create a new buffer imo.  that'd cover things like EISDIR and such.

Mike Frysinger <vapier>
Project Member
Wed 24 Jun 2015 07:18:32 PM UTC, comment #1: 

I agree.  But... when typing in the name of a file that doesn't exist after a ^R in multibuffer mode, should nano open an empty buffer with the specified name (as it does now) or should it report an error (as I would expect, because most likely the given name contains a typo)?

The thing is, when doing ^R in multibuffer mode, nano behaves as if the things you type were given on the command line.  And I think it shouldn't.  For ^R it should report the same error messages when not in multibuffer mode.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 23 Jun 2015 06:23:04 PM UTC, original submission:  

when loading a file into a new buffer, errors should result in just an error message rather than a new buffer

for example:
$ nano -F /etc/passwd
<see new buffer for "/etc/passwd" file>
<CTRL+R for insert file into new buffer>
<type "/" for the root dir>
<hit enter>
<a new buffer is created with the error message [ "/" is a directory ]>

imo, a new buffer should not be created at all, but instead the active buffer should have the error message displayed

Mike Frysinger <vapier>
Project Member

 

Attached Files
file #34319:  get-out-on-no-file.patch added by bens (1KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by vapier (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 logged-in users can vote.

     

     

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-07 bens Open/ClosedOpen => Closed
    2015-07-18 bens StatusIn Progress => Fixed
    2015-07-04 bens Attached File- => Added file-exists-and-is-normal.patch, #34377
    2015-06-28 bens Attached File- => Added verify-that-file-exists.patch, #34335
    2015-06-28 bens Attached File- => Added verify-that-file-exists.patch, #34333
    2015-06-25 bens Attached File- => Added get-out-on-failed-open.patch, #34318
        Attached File- => Added get-out-on-no-file.patch, #34319
        StatusNone => In Progress
        Assigned toNone => bens

    Back to the top


    Powered by Savane 3.5