diff --git a/man/scrot.1 b/man/scrot.1 index 9318b51..175f532 100644 --- a/man/scrot.1 +++ b/man/scrot.1 @@ -97,6 +97,10 @@ Capture the mouse pointer. .B \fB-f\fP, \fB--freeze\fP Freeze the screen when the selection is used: \fB--select\fP +.TP +.B +\fB-o\fP, \fB--overwrite\fP +By default \fBscrot\fP does not overwrite the files, use this option to allow it. .RE .PP diff --git a/man/scrot.txt b/man/scrot.txt index 43cef81..ccc661f 100644 --- a/man/scrot.txt +++ b/man/scrot.txt @@ -40,6 +40,7 @@ OPTIONS -z, --silent Prevent beeping. -p, --pointer Capture the mouse pointer. -f, --freeze Freeze the screen when the selection is used: --select + -o, --overwrite By default scrot does not overwrite the files, use this option to allow it. SPECIAL STRINGS diff --git a/src/main.c b/src/main.c index b0dac9d..64f7dc9 100644 --- a/src/main.c +++ b/src/main.c @@ -177,17 +177,16 @@ char* scrot_have_file_extension(char *filename) void scrot_check_if_overwrite_file(char **filename) { - const int max_count = 999; - static int count = 0; char *curfile = *filename; - if (opt.overwrite) return; + if (opt.overwrite == 1) return; if (access(curfile, F_OK) == -1) return; + const int max_count = 999; + static int count = 0; const char *extension = scrot_have_file_extension(curfile); const size_t slen = strlen(curfile); - int nalloc = slen + 4 + 1; // _000 + NUL byte char fmt[5]; char *newname = NULL; diff --git a/src/options.c b/src/options.c index 7d7c611..c700585 100644 --- a/src/options.c +++ b/src/options.c @@ -45,7 +45,7 @@ init_parse_options(int argc, char **argv) memset(&opt, 0, sizeof(scrotoptions)); opt.quality = 75; - opt.overwrite = 1; + opt.overwrite = 0; /* Parse the cmdline args */ scrot_parse_option_array(argc, argv); @@ -78,7 +78,7 @@ parse_option_required_number(char *str) static void scrot_parse_option_array(int argc, char **argv) { - static char stropts[] = "a:o:fpbcd:e:hmq:st:uv+:z"; + static char stropts[] = "a:ofpbcd:e:hmq:st:uv+:z"; static struct option lopts[] = { /* actions */ {"help", 0, 0, 'h'}, /* okay */ @@ -92,8 +92,8 @@ scrot_parse_option_array(int argc, char **argv) {"silent", 0, 0, 'z'}, {"pointer", 0, 0, 'p'}, {"freeze", 0, 0, 'f'}, + {"overwrite", 0, 0, 'o'}, /* toggles */ - {"overwrite", 1, 0, 'o'}, {"thumb", 1, 0, 't'}, {"delay", 1, 0, 'd'}, {"quality", 1, 0, 'q'}, @@ -158,7 +158,7 @@ scrot_parse_option_array(int argc, char **argv) opt.freeze = 1; break; case 'o': - opt.overwrite = !!parse_option_required_number(optarg); + opt.overwrite = 1; break; case 'a': options_parse_autoselect(optarg); @@ -324,9 +324,10 @@ show_usage(void) " -t, --thumb NUM generate thumbnail too. NUM is the percentage\n" " of the original size for the thumbnail to be,\n" " or the geometry in percent, e.g. 50x60 or 80x20.\n" - " -z, --silent Prevent beeping\n" + " -z, --silent Prevent beeping\n" " -p, --pointer Capture the mouse pointer.\n" " -f, --freeze Freeze the screen when the selection is used: --select\n" + " -o, --overwrite By default " PACKAGE " does not overwrite the files, use this option to allow it.\n" "\n" " SPECIAL STRINGS\n" " Both the --exec and filename parameters can take format specifiers\n"