bugGNU Screen - Bugs: bug #29398, command 'hardcopy -h' without...

 
 

bug #29398: command 'hardcopy -h' without filename uses '-h' as filename instead of as flag

Submitted by:  None
Submitted on:  Thu 01 Apr 2010 12:26:27 AM UTC  
 
Category: Program LogicSeverity: 3 - Normal
Priority: 5 - NormalStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: ClosedRelease: Cur Dev Sources
Fixed Release: 4.1.0Planned Release: None
Work Required: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 01 Apr 2010 08:04:14 PM UTC, comment #1:

Hi. Thanks for the patch! I have changed it a little so it looks more readable to me. Please try it out and see if it behaves the same way as you expected it.

http://git.savannah.gnu.org/gitweb/?p=screen.git;a=commit;h=fd8832ccdbf807fe9a6ecd04d6166191c3b7ae90

Sadrul Habib Chowdhury <sadrul>
Project Administrator
Thu 01 Apr 2010 12:26:27 AM UTC, original submission:

The command
:hardcopy -h
(hardcopy [-h] [file]; saves currently displayed image to file or hardcopy.n, also scrollback buffer with -h)
instead of saving both display and scrollback to hardcopy.n saves only the currently displayed image, to a file named '-h'.

The difference is simply the condition
argc > 1
to only use -h if there's a second argument
vs
argc >= 1
to make sure there's at least one argument to check if it's '-h'
or
*args
to do the same (which seems to be the more commonly used condition elsewhere in the file)

Since the attached patches are so short they're reproduced below.

The first makes -h save scrollback with or without a file name given.

The second preserves the unlikely case in which someone actually does want to save display to '-h'; with
:hardcopy -- -h
or, to save both history and display to '-h'
:hardcopy -h -h
works as it always has
:hardcopy --
:hardcopy -h --
will, as they always have, save display or history and display to '--'.

diff --git a/src/process.c b/src/process.c
index cc2b56f..3a39c60 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1272,7 +1272,7 @@ int key;
{
int mode = DUMP_HARDCOPY;

- if (argc > 1 && !strcmp(*args, "-h"))
+ if (args && !strcmp(args, "-h"))
{
mode = DUMP_SCROLLBACK;
args++;

diff --git a/src/process.c b/src/process.c
index 3a39c60..3b9ba54 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1272,7 +1272,12 @@ int key;
{
int mode = DUMP_HARDCOPY;

- if (args && !strcmp(args, "-h"))
+ if (argc > 1 && !strcmp(*args, "--"))
+ {
+ args++;
+ argc--;
+ }
+ else if (args && !strcmp(args, "-h"))
{
mode = DUMP_SCROLLBACK;
args++;

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by sadrul (Posted a comment)
  •  

    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 logged-in users can vote.

     

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

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 01 Apr 2010 08:04:14 PM UTCsadrulStatusNone=>Fixed
      Open/ClosedOpen=>Closed
      Fixed ReleaseNone=>4.1.0
    Thu 01 Apr 2010 12:26:27 AM UTCNoneAttached File-=>Added 0001-change-hardcopy-argument-parsing-so-h-without-file-s.patch, #20080
      Attached File-=>Added 0002-change-hardcopy-argument-parsing-so-h-saves-display-.patch, #20081

    Back to the top


    Powered by Savane 3.1-cleanup1