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

 
 

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

Submitter:  None
Submitted:  Thu 01 Apr 2010 12:26:27 AM UTC
   
 
Category:  Program Logic Severity:  3 - Normal
Priority:  * 5 - Normal Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Release:  Cur Dev Sources
Fixed Release:  4.1.0 Planned Release:  None
Work Required:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-04-01 sadrul StatusNone Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.1.0
    2010-04-01 None Attached 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.13-d3ae.
    Corresponding source code