Skip to content

Commit

Permalink
srtzip: Protect against accidentally overwriting an input file
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Aug 26, 2015
1 parent 24eae76 commit ff06a22
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions srtzip.pike
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ff06a22

Please sign in to comment.