URL: <http://savannah.gnu.org/bugs/?29398>
Summary: command 'hardcopy -h' without filename uses '-h' as filename instead of as flag Project: GNU Screen Submitted by: None Submitted on: Thu 01 Apr 2010 12:26:27 AM UTC Category: Program Logic Severity: 3 - Normal Priority: 5 - Normal Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Release: Cur Dev Sources Fixed Release: None Planned Release: None Work Required: None _______________________________________________________ Details: 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++; _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Thu 01 Apr 2010 12:26:27 AM UTC Name: 0001-change-hardcopy-argument-parsing-so-h-without-file-s.patch Size: 661B By: None <http://savannah.gnu.org/bugs/download.php?file_id=20080> ------------------------------------------------------- Date: Thu 01 Apr 2010 12:26:27 AM UTC Name: 0002-change-hardcopy-argument-parsing-so-h-saves-display-.patch Size: 738B By: None <http://savannah.gnu.org/bugs/download.php?file_id=20081> _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?29398> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/