Fit to Plan 9's ANSI/POSIX compatibility layer
tr(1) of ANSI/POSIX environment, aka APE, don't support \n literal. It's handles only octal(\ooo) or hexadecimal(\xhhhh) numbers. And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character. * close -> cl * continue -> cont (cnt is used for count) * line -> ln * hered -> hdoc * shell -> sh * string -> str Signed-off-by: Kyohei Kadota <lufia@lufia.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kyohei Kadota committed
Sep 10, 2020 at 02:17 UTC
b3b753b1043d847c1a4cf114781f1b0e3c6084e7
2 files changed
+34
-34
generate-cmdlist.sh
+1
-1
@@ -10,7 +10,7 @@ command_list () {
10
}
11
12
get_categories () {
13
- tr ' ' '\n'|
13
+ tr ' ' '\012'|
14
grep -v '^$' |
15
sort |
16
uniq
t/chainlint.sed
+33
-33
@@ -117,7 +117,7 @@
117
/^[ ]*!*[ ]*(..*)[ ]*[0-9]*[<>|&]/boneline
118
119
# multi-line "(...\n...)"
120
-/^[ ]*(/bsubshell
120
+/^[ ]*(/bsubsh
121
122
# innocuous line -- print it and advance to next line
123
b
@@ -130,11 +130,11 @@ b
130
}
131
b
132
133
-:subshell
133
+:subsh
134
# bare "(" line? -- stash for later printing
135
/^[ ]*([ ]*$/ {
136
h
137
- bnextline
137
+ bnextln
138
}
139
# "(..." line -- split off and stash "(", then process "..." as its own line
140
x
@@ -143,7 +143,7 @@ x
143
s/(//
144
bslurp
145
146
-:nextline
146
+:nextln
147
N
148
s/.*\n//
149
@@ -151,10 +151,10 @@ s/.*\n//
151
# incomplete line "...\"
152
/\\$/bicmplte
153
# multi-line quoted string "...\n..."?
154
-/"/bdqstring
154
+/"/bdqstr
155
# multi-line quoted string '...\n...'? (but not contraction in string "it's")
156
/'/{
157
- /"[^'"]*'[^'"]*"/!bsqstring
157
+ /"[^'"]*'[^'"]*"/!bsqstr
158
}
159
:folded
160
# here-doc -- swallow it
@@ -163,8 +163,8 @@ s/.*\n//
163
# before closing ")", "done", "elsif", "else", or "fi" will need to be
164
# re-visited to drop "suspect" marking since final line of those constructs
165
# legitimately lacks "&&", so "suspect" mark must be removed
166
-/^[ ]*#/bnextline
167
-/^[ ]*$/bnextline
166
+/^[ ]*#/bnextln
167
+/^[ ]*$/bnextln
168
# in-line comment -- strip it (but not "#" in a string, Bash ${#...} array
169
# length, or Perforce "//depot/path#42" revision in filespec)
170
/[ ]#/{
@@ -175,22 +175,22 @@ s/.*\n//
175
# multi-line "case ... esac"
176
/^[ ]*case[ ]..*[ ]in/bcase
177
# multi-line "for ... done" or "while ... done"
178
-/^[ ]*for[ ]..*[ ]in/bcontinue
179
-/^[ ]*while[ ]/bcontinue
180
-/^[ ]*do[ ]/bcontinue
181
-/^[ ]*do[ ]*$/bcontinue
182
-/;[ ]*do/bcontinue
178
+/^[ ]*for[ ]..*[ ]in/bcont
179
+/^[ ]*while[ ]/bcont
180
+/^[ ]*do[ ]/bcont
181
+/^[ ]*do[ ]*$/bcont
182
+/;[ ]*do/bcont
183
/^[ ]*done[ ]*&&[ ]*$/bdone
184
/^[ ]*done[ ]*$/bdone
185
/^[ ]*done[ ]*[<>|]/bdone
186
/^[ ]*done[ ]*)/bdone
187
-/||[ ]*exit[ ]/bcontinue
188
-/||[ ]*exit[ ]*$/bcontinue
187
+/||[ ]*exit[ ]/bcont
188
+/||[ ]*exit[ ]*$/bcont
189
# multi-line "if...elsif...else...fi"
190
-/^[ ]*if[ ]/bcontinue
191
-/^[ ]*then[ ]/bcontinue
192
-/^[ ]*then[ ]*$/bcontinue
193
-/;[ ]*then/bcontinue
190
+/^[ ]*if[ ]/bcont
191
+/^[ ]*then[ ]/bcont
192
+/^[ ]*then[ ]*$/bcont
193
+/;[ ]*then/bcont
194
/^[ ]*elif[ ]/belse
195
/^[ ]*elif[ ]*$/belse
196
/^[ ]*else[ ]/belse
@@ -234,10 +234,10 @@ s/.*\n//
234
}
235
}
236
# line ends with pipe "...|" -- valid; not missing "&&"
237
-/|[ ]*$/bcontinue
237
+/|[ ]*$/bcont
238
# missing end-of-line "&&" -- mark suspect
239
/&&[ ]*$/!s/^/?!AMP?!/
240
-:continue
240
+:cont
241
# retrieve and print previous line
242
x
243
n
@@ -250,7 +250,7 @@ s/\\\n//
250
bslurp
251
252
# check for multi-line double-quoted string "...\n..." -- fold to one line
253
-:dqstring
253
+:dqstr
254
# remove all quote pairs
255
s/"\([^"]*\)"/@!\1@!/g
256
# done if no dangling quote
@@ -258,13 +258,13 @@ s/"\([^"]*\)"/@!\1@!/g
258
# otherwise, slurp next line and try again
259
N
260
s/\n//
261
-bdqstring
261
+bdqstr
262
:dqdone
263
s/@!/"/g
264
bfolded
265
266
# check for multi-line single-quoted string '...\n...' -- fold to one line
267
-:sqstring
267
+:sqstr
268
# remove all quote pairs
269
s/'\([^']*\)'/@!\1@!/g
270
# done if no dangling quote
@@ -272,7 +272,7 @@ s/'\([^']*\)'/@!\1@!/g
272
# otherwise, slurp next line and try again
273
N
274
s/\n//
275
-bsqstring
275
+bsqstr
276
:sqdone
277
s/@!/'/g
278
bfolded
@@ -282,11 +282,11 @@ bfolded
282
:heredoc
283
s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
284
s/[ ]*<<//
285
-:heredsub
285
+:hdocsub
286
N
287
/^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{
288
s/\n.*$//
289
- bheredsub
289
+ bhdocsub
290
}
291
s/^<[^>]*>//
292
s/\n.*$//
@@ -305,7 +305,7 @@ bcase
305
x
306
s/?!AMP?!//
307
x
308
-bcontinue
308
+bcont
309
310
# found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
311
# "suspect" from final contained line since that line legitimately lacks "&&"
@@ -321,10 +321,10 @@ bchkchn
321
# found nested multi-line "(...\n...)" -- pass through untouched
322
:nest
323
x
324
-:nstslurp
324
+:nstslrp
325
n
326
# closing ")" on own line -- stop nested slurp
327
-/^[ ]*)/bnstclose
327
+/^[ ]*)/bnstcl
328
# comment -- not closing ")" if in comment
329
/^[ ]*#/bnstcnt
330
# "$((...))" -- arithmetic expansion; not closing ")"
@@ -332,11 +332,11 @@ n
332
# "$(...)" -- command substitution; not closing ")"
333
/\$([^)][^)]*)[^)]*$/bnstcnt
334
# closing "...)" -- stop nested slurp
335
-/)/bnstclose
335
+/)/bnstcl
336
:nstcnt
337
x
338
-bnstslurp
339
-:nstclose
338
+bnstslrp
339
+:nstcl
340
s/^/>>/
341
# is it "))" which closes nested and parent subshells?
342
/)[ ]*)/bslurp