Browse code

escape - and 'Cache-Control' items in manpage

Suggested by Debian patches. This automatically escapes dashes and
the word 'Cache-Control' in the generated manpage.

There is still an instance where the word Cache-Control is getting
split across newlines due to the 80-character limit, which it doesn't
catch, but it doesn't break the formatting of the rest of the
manpage. It just looks like 'Cache- Control' in the result (note the
extra space after the dash). I'll live with that.

Matt Domsch authored on 2015/03/19 00:06:06
Showing 1 changed files
... ...
@@ -19,6 +19,7 @@ while (<>) {
19 19
 			($desc = $_) =~ s/^\s*(.*?)\s*$/$1/;
20 20
 			($cmdline = <>) =~ s/^\s*s3cmd (.*?) (.*?)\s*$/s3cmd \\fB$1\\fR \\fI$2\\fR/;
21 21
 			$cmd = $1;
22
+			$cmdline =~ s/-/\\-/g;
22 23
 			if ($cmd =~ /^cf/) {
23 24
 				$cfcommands .= ".TP\n$cmdline\n$desc\n";
24 25
 			} elsif ($cmd =~ /^ws/) {
... ...
@@ -41,11 +42,16 @@ while (<>) {
41 41
 					($opt, $desc) = split(/\s\s+/, $opt, 2);
42 42
 				}
43 43
 				$opt =~ s/(-[^ ,=\.]+)/\\fB$1\\fR/g;
44
+				# escape all single dashes
44 45
 				$opt =~ s/-/\\-/g;
45 46
 				$options .= ".TP\n$opt\n";
46 47
 			} else {
47 48
 				$_ =~ s/\s*(.*?)\s*$/$1/;
48 49
 				$_ =~ s/(--[^ ,=\.]+)/\\fB$1\\fR/g;
50
+				# escape word 'Cache-Control'
51
+				$_ =~ s/'(\S+-\S+)'/\\&'$1'/g;
52
+				# escape all single dashes
53
+				$_ =~ s/-/\\-/g;
49 54
 				$desc .= $_;
50 55
 			}
51 56
 			if ($desc) {
... ...
@@ -55,8 +61,8 @@ while (<>) {
55 55
 	}
56 56
 }
57 57
 print "
58
-.\\\" !!! IMPORTANT: This file is generated from s3cmd --help output using format-manpage.pl
59
-.\\\" !!!            Do your changes either in s3cmd file or in 'format-manpage.pl' otherwise
58
+.\\\" !!! IMPORTANT: This file is generated from s3cmd \\-\\-help output using format-manpage.pl
59
+.\\\" !!!            Do your changes either in s3cmd file or in 'format\\-manpage.pl' otherwise
60 60
 .\\\" !!!            they will be overwritten!
61 61
 
62 62
 .TH s3cmd 1
... ...
@@ -104,11 +110,11 @@ synchronising complete directory trees to or from remote S3 storage. To some ext
104 104
 .PP
105 105
 Basic usage common in backup scenarios is as simple as:
106 106
 .nf
107
-	s3cmd sync /local/path/ s3://test-bucket/backup/
107
+	s3cmd sync /local/path/ s3://test\\-bucket/backup/
108 108
 .fi
109 109
 .PP
110 110
 This command will find all files under /local/path directory and copy them 
111
-to corresponding paths under s3://test-bucket/backup on the remote side.
111
+to corresponding paths under s3://test\\-bucket/backup on the remote side.
112 112
 For example:
113 113
 .nf
114 114
 	/local/path/\\fBfile1.ext\\fR         \\->  s3://bucket/backup/\\fBfile1.ext\\fR
... ...
@@ -118,7 +124,7 @@ For example:
118 118
 However if the local path doesn't end with a slash the last directory's name
119 119
 is used on the remote side as well. Compare these with the previous example:
120 120
 .nf
121
-	s3cmd sync /local/path s3://test-bucket/backup/
121
+	s3cmd sync /local/path s3://test\\-bucket/backup/
122 122
 .fi
123 123
 will sync:
124 124
 .nf
... ...
@@ -128,7 +134,7 @@ will sync:
128 128
 .PP
129 129
 To retrieve the files back from S3 use inverted syntax:
130 130
 .nf
131
-	s3cmd sync s3://test-bucket/backup/ /tmp/restore/
131
+	s3cmd sync s3://test\\-bucket/backup/ /tmp/restore/
132 132
 .fi
133 133
 that will download files:
134 134
 .nf
... ...
@@ -139,7 +145,7 @@ that will download files:
139 139
 Without the trailing slash on source the behaviour is similar to 
140 140
 what has been demonstrated with upload:
141 141
 .nf
142
-	s3cmd sync s3://test-bucket/backup /tmp/restore/
142
+	s3cmd sync s3://test\\-bucket/backup /tmp/restore/
143 143
 .fi
144 144
 will download the files as:
145 145
 .nf
... ...
@@ -155,8 +161,8 @@ For the purpose of \\fB\\-\\-exclude\\fR and \\fB\\-\\-include\\fR matching only
155 155
 bold file names above are used. For instance only \\fBpath/file1.ext\\fR is tested
156 156
 against the patterns, not \\fI/local/\\fBpath/file1.ext\\fR
157 157
 .PP
158
-Both \\fB\\-\\-exclude\\fR and \\fB\\-\\-include\\fR work with shell-style wildcards (a.k.a. GLOB).
159
-For a greater flexibility s3cmd provides Regular-expression versions of the two exclude options 
158
+Both \\fB\\-\\-exclude\\fR and \\fB\\-\\-include\\fR work with shell\\-style wildcards (a.k.a. GLOB).
159
+For a greater flexibility s3cmd provides Regular\\-expression versions of the two exclude options 
160 160
 named \\fB\\-\\-rexclude\\fR and \\fB\\-\\-rinclude\\fR. 
161 161
 The options with ...\\fB\\-from\\fR suffix (eg \\-\\-rinclude\\-from) expect a filename as
162 162
 an argument. Each line of such a file is treated as one pattern.
... ...
@@ -171,7 +177,7 @@ about matching file names against exclude and include rules.
171 171
 .PP
172 172
 For example to exclude all files with \".jpg\" extension except those beginning with a number use:
173 173
 .PP
174
-	\\-\\-exclude '*.jpg' \\-\\-rinclude '[0-9].*\\.jpg'
174
+	\\-\\-exclude '*.jpg' \\-\\-rinclude '[0\\-9].*\\.jpg'
175 175
 .PP
176 176
 To exclude all files except \"*.jpg\" extension, use:
177 177
 .PP
... ...
@@ -206,7 +212,7 @@ or visit the project homepage:
206 206
 Report bugs to 
207 207
 .I s3tools\\-bugs\@lists.sourceforge.net
208 208
 .SH COPYRIGHT
209
-Copyright \\(co 2007-2014 TGRMN Software - http://www.tgrmn.com - and contributors
209
+Copyright \\(co 2007\\-2014 TGRMN Software \\- http://www.tgrmn.com \\- and contributors
210 210
 .br
211 211
 .SH LICENSE
212 212
 This program is free software; you can redistribute it and/or modify