bugGNU nano - Bugs: bug #56310, reading stuff from standard input...

 
 

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

bug #56310: reading stuff from standard input does not report the number of lines

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Sun 12 May 2019 12:26:58 PM UTC  
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  Benno Schulenberg <bens> Open/Closed:  Closed

( Jump to the original submission)

Wed 19 Jun 2019 06:29:50 AM UTC, comment #10: 

Released in nano-4.3.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 28 May 2019 03:08:19 PM UTC, comment #9: 

Fixed in master, commit d946f38a.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 28 May 2019 09:33:16 AM UTC, comment #8: 

And here is the proposed commit.

(file #46986)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 28 May 2019 08:49:46 AM UTC, comment #7: 

Yeah, don't know what I did there.  Here is the right one.

(file #46985)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 27 May 2019 08:43:41 PM UTC, comment #6: 

Is file #46980 the wrong upload?

Brand Huntsman <brand>
Mon 27 May 2019 06:30:29 PM UTC, comment #5: 

Here is what I currently have.  With some more changes, this allows nperror() to be deleted entirely, and the isendwin() chunk in statusline() too.

(file #46980)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 17 May 2019 11:16:31 AM UTC, comment #4: 

First patch fixes nperror so ^C won't display statusbar, since that might be unsafe. Second patch stores the message that would have been output to stderr and redraws it after enabling ncurses. I can clean it up if you approve.

The stray period still needs to be removed, but kind of looks nice.

The input_was_aborted variable could probably also be removed, since ^C no longer enters curses mode.

(file #46919, file #46920)

Brand Huntsman <brand>
Fri 17 May 2019 09:28:43 AM UTC, comment #3: 

Please stop telling what the code does.  I know what it does; I can read.

The thing is, when you add an 'else {endwin(); doupdate(); kill(0, SIGINT);}', it works fine for reading stuff from the terminal with 'src/nano -' and endig with ^D, but it messes up the terminal state when piping something into nano with for example 'cat README | src/nano -'.  I don't understand why those two things behave differently.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 17 May 2019 08:40:46 AM UTC, comment #2: 

^C triggers nperror() in read_file() which calls doupdate(), and isendwin() returns false after that.

if (ferror(f))
nperror(filename);
else {endwin();doupdate();input_was_aborted=true;}

That 'else' clause causes ^D to display the message on statusbar, but input_was_aborted needs to be global. It should only be called if filename=="stdin".

But is this safe? If it is, why does statusline() even bother writing to stderr? If not safe, the nperror() call should be fixed so statusline() writes to stderr for ^C. And then have statusline() store the current message and after ncurses is initialized, call a function to redisplay the previous message.

Brand Huntsman <brand>
Fri 17 May 2019 07:56:45 AM UTC, comment #1: 

That period is from line 1103 in nano.c. The \n should be moved into statusline().

    read_file(stream, 0, "stdin", TRUE);
    openfile->edittop = openfile->filetop;

>   fprintf(stderr, ".\n");


The message is produced by a statusline() in read_file(). But statusline() draws it to stderr because of isendwin(). ^C some how inits ncurses in read_file() in the section after sigwinch is unblocked, but ^D doesn't and so it writes to stderr.

Brand Huntsman <brand>
Sun 12 May 2019 12:26:58 PM UTC, original submission:  

To reproduce, run:

  cat README | nano -

The contents of the README file have been read into a new buffer, and the cursor is put at the end of it, but there is no message on the status bar about the number of lines that were read.

In a way, this could be seen as a nice distinction between reading from standard input and reading a file directly, but...

Now type ^X N, and see that on the terminal it says "Read 79 lines."  This is... the wrong place, and the info comes too late.

But when you run 'nano -', type a few characters and then <Enter> ^C, there is a period the "[ Read 1 line ]" is shown on the status bar.  (Additional buglet: there is a period after that message.)

Expected behavior: no matter whether piping a file into nano, terminating the input with ^D or ^D^D or ^C, they all should put the number of read lines on the status bar.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by brand (Posted a comment)
  • -email is unavailable- added by bens (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-19 bens Open/ClosedOpen => Closed
    2019-05-28 bens StatusIn Progress => Fixed
    2019-05-28 bens Attached File- => Added 0001-files-when-needed-reconnect-the-keyboard-and-reenter.patch, #46986
    2019-05-28 bens Attached File- => Added reconnect-reenter.patch, #46985
    2019-05-28 bens Attached File#46980 => Removed
    2019-05-27 bens Attached File- => Added reconnect-reenter.patch, #46980
    2019-05-27 bens StatusNone => In Progress
        Assigned toNone => bens
    2019-05-17 brand Attached File- => Added 0001-utils-preserve-curses-mode-when-calling-nperror.patch, #46919
        Attached File- => Added 0002-store-status-message-written-to-stderr-and-redisplay.patch, #46920

    Back to the top


    Powered by Savane 3.5