From ff06a22196916bbc543b7496a871abd4336334c8 Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Thu, 27 Aug 2015 00:46:21 +1000 Subject: [PATCH] srtzip: Protect against accidentally overwriting an input file --- srtzip.pike | 1 + 1 file changed, 1 insertion(+) diff --git a/srtzip.pike b/srtzip.pike index dfa7847c..993e1945 100644 --- a/srtzip.pike +++ b/srtzip.pike @@ -12,6 +12,7 @@ int main(int argc,array(string) argv) string outfn=files[-1]; files=files[..<1]-({outfn}); if (sizeof(files)<2) exit(0,"USAGE: pike %s input1.srt input2.srt [input3.srt...] output.srt\nAttempts to 'zip' the inputs into the output.\n"); + if (!opt->clobber && file_stat(outfn)) exit(0,"Refusing to clobber %s\n",outfn); write("Combining to %s:\n%{\t%s\n%}",outfn,files); array(array(string)) inputs=String.trim_all_whites(utf8_to_string(Stdio.read_file(files[*])[*])[*])[*]/"\n\n"; //Trim off all index markers. We can re-add them later if they're wanted.