mirror of
https://github.com/git/git.git
synced 2024-05-03 22:16:01 +02:00
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>
This commit is contained in:
parent
54e85e7af1
commit
b3b753b104
|
@ -10,7 +10,7 @@ command_list () {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_categories () {
|
get_categories () {
|
||||||
tr ' ' '\n'|
|
tr ' ' '\012'|
|
||||||
grep -v '^$' |
|
grep -v '^$' |
|
||||||
sort |
|
sort |
|
||||||
uniq
|
uniq
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
/^[ ]*!*[ ]*(..*)[ ]*[0-9]*[<>|&]/boneline
|
/^[ ]*!*[ ]*(..*)[ ]*[0-9]*[<>|&]/boneline
|
||||||
|
|
||||||
# multi-line "(...\n...)"
|
# multi-line "(...\n...)"
|
||||||
/^[ ]*(/bsubshell
|
/^[ ]*(/bsubsh
|
||||||
|
|
||||||
# innocuous line -- print it and advance to next line
|
# innocuous line -- print it and advance to next line
|
||||||
b
|
b
|
||||||
|
@ -130,11 +130,11 @@ b
|
||||||
}
|
}
|
||||||
b
|
b
|
||||||
|
|
||||||
:subshell
|
:subsh
|
||||||
# bare "(" line? -- stash for later printing
|
# bare "(" line? -- stash for later printing
|
||||||
/^[ ]*([ ]*$/ {
|
/^[ ]*([ ]*$/ {
|
||||||
h
|
h
|
||||||
bnextline
|
bnextln
|
||||||
}
|
}
|
||||||
# "(..." line -- split off and stash "(", then process "..." as its own line
|
# "(..." line -- split off and stash "(", then process "..." as its own line
|
||||||
x
|
x
|
||||||
|
@ -143,7 +143,7 @@ x
|
||||||
s/(//
|
s/(//
|
||||||
bslurp
|
bslurp
|
||||||
|
|
||||||
:nextline
|
:nextln
|
||||||
N
|
N
|
||||||
s/.*\n//
|
s/.*\n//
|
||||||
|
|
||||||
|
@ -151,10 +151,10 @@ s/.*\n//
|
||||||
# incomplete line "...\"
|
# incomplete line "...\"
|
||||||
/\\$/bicmplte
|
/\\$/bicmplte
|
||||||
# multi-line quoted string "...\n..."?
|
# multi-line quoted string "...\n..."?
|
||||||
/"/bdqstring
|
/"/bdqstr
|
||||||
# multi-line quoted string '...\n...'? (but not contraction in string "it's")
|
# multi-line quoted string '...\n...'? (but not contraction in string "it's")
|
||||||
/'/{
|
/'/{
|
||||||
/"[^'"]*'[^'"]*"/!bsqstring
|
/"[^'"]*'[^'"]*"/!bsqstr
|
||||||
}
|
}
|
||||||
:folded
|
:folded
|
||||||
# here-doc -- swallow it
|
# here-doc -- swallow it
|
||||||
|
@ -163,8 +163,8 @@ s/.*\n//
|
||||||
# before closing ")", "done", "elsif", "else", or "fi" will need to be
|
# before closing ")", "done", "elsif", "else", or "fi" will need to be
|
||||||
# re-visited to drop "suspect" marking since final line of those constructs
|
# re-visited to drop "suspect" marking since final line of those constructs
|
||||||
# legitimately lacks "&&", so "suspect" mark must be removed
|
# legitimately lacks "&&", so "suspect" mark must be removed
|
||||||
/^[ ]*#/bnextline
|
/^[ ]*#/bnextln
|
||||||
/^[ ]*$/bnextline
|
/^[ ]*$/bnextln
|
||||||
# in-line comment -- strip it (but not "#" in a string, Bash ${#...} array
|
# in-line comment -- strip it (but not "#" in a string, Bash ${#...} array
|
||||||
# length, or Perforce "//depot/path#42" revision in filespec)
|
# length, or Perforce "//depot/path#42" revision in filespec)
|
||||||
/[ ]#/{
|
/[ ]#/{
|
||||||
|
@ -175,22 +175,22 @@ s/.*\n//
|
||||||
# multi-line "case ... esac"
|
# multi-line "case ... esac"
|
||||||
/^[ ]*case[ ]..*[ ]in/bcase
|
/^[ ]*case[ ]..*[ ]in/bcase
|
||||||
# multi-line "for ... done" or "while ... done"
|
# multi-line "for ... done" or "while ... done"
|
||||||
/^[ ]*for[ ]..*[ ]in/bcontinue
|
/^[ ]*for[ ]..*[ ]in/bcont
|
||||||
/^[ ]*while[ ]/bcontinue
|
/^[ ]*while[ ]/bcont
|
||||||
/^[ ]*do[ ]/bcontinue
|
/^[ ]*do[ ]/bcont
|
||||||
/^[ ]*do[ ]*$/bcontinue
|
/^[ ]*do[ ]*$/bcont
|
||||||
/;[ ]*do/bcontinue
|
/;[ ]*do/bcont
|
||||||
/^[ ]*done[ ]*&&[ ]*$/bdone
|
/^[ ]*done[ ]*&&[ ]*$/bdone
|
||||||
/^[ ]*done[ ]*$/bdone
|
/^[ ]*done[ ]*$/bdone
|
||||||
/^[ ]*done[ ]*[<>|]/bdone
|
/^[ ]*done[ ]*[<>|]/bdone
|
||||||
/^[ ]*done[ ]*)/bdone
|
/^[ ]*done[ ]*)/bdone
|
||||||
/||[ ]*exit[ ]/bcontinue
|
/||[ ]*exit[ ]/bcont
|
||||||
/||[ ]*exit[ ]*$/bcontinue
|
/||[ ]*exit[ ]*$/bcont
|
||||||
# multi-line "if...elsif...else...fi"
|
# multi-line "if...elsif...else...fi"
|
||||||
/^[ ]*if[ ]/bcontinue
|
/^[ ]*if[ ]/bcont
|
||||||
/^[ ]*then[ ]/bcontinue
|
/^[ ]*then[ ]/bcont
|
||||||
/^[ ]*then[ ]*$/bcontinue
|
/^[ ]*then[ ]*$/bcont
|
||||||
/;[ ]*then/bcontinue
|
/;[ ]*then/bcont
|
||||||
/^[ ]*elif[ ]/belse
|
/^[ ]*elif[ ]/belse
|
||||||
/^[ ]*elif[ ]*$/belse
|
/^[ ]*elif[ ]*$/belse
|
||||||
/^[ ]*else[ ]/belse
|
/^[ ]*else[ ]/belse
|
||||||
|
@ -234,10 +234,10 @@ s/.*\n//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# line ends with pipe "...|" -- valid; not missing "&&"
|
# line ends with pipe "...|" -- valid; not missing "&&"
|
||||||
/|[ ]*$/bcontinue
|
/|[ ]*$/bcont
|
||||||
# missing end-of-line "&&" -- mark suspect
|
# missing end-of-line "&&" -- mark suspect
|
||||||
/&&[ ]*$/!s/^/?!AMP?!/
|
/&&[ ]*$/!s/^/?!AMP?!/
|
||||||
:continue
|
:cont
|
||||||
# retrieve and print previous line
|
# retrieve and print previous line
|
||||||
x
|
x
|
||||||
n
|
n
|
||||||
|
@ -250,7 +250,7 @@ s/\\\n//
|
||||||
bslurp
|
bslurp
|
||||||
|
|
||||||
# check for multi-line double-quoted string "...\n..." -- fold to one line
|
# check for multi-line double-quoted string "...\n..." -- fold to one line
|
||||||
:dqstring
|
:dqstr
|
||||||
# remove all quote pairs
|
# remove all quote pairs
|
||||||
s/"\([^"]*\)"/@!\1@!/g
|
s/"\([^"]*\)"/@!\1@!/g
|
||||||
# done if no dangling quote
|
# done if no dangling quote
|
||||||
|
@ -258,13 +258,13 @@ s/"\([^"]*\)"/@!\1@!/g
|
||||||
# otherwise, slurp next line and try again
|
# otherwise, slurp next line and try again
|
||||||
N
|
N
|
||||||
s/\n//
|
s/\n//
|
||||||
bdqstring
|
bdqstr
|
||||||
:dqdone
|
:dqdone
|
||||||
s/@!/"/g
|
s/@!/"/g
|
||||||
bfolded
|
bfolded
|
||||||
|
|
||||||
# check for multi-line single-quoted string '...\n...' -- fold to one line
|
# check for multi-line single-quoted string '...\n...' -- fold to one line
|
||||||
:sqstring
|
:sqstr
|
||||||
# remove all quote pairs
|
# remove all quote pairs
|
||||||
s/'\([^']*\)'/@!\1@!/g
|
s/'\([^']*\)'/@!\1@!/g
|
||||||
# done if no dangling quote
|
# done if no dangling quote
|
||||||
|
@ -272,7 +272,7 @@ s/'\([^']*\)'/@!\1@!/g
|
||||||
# otherwise, slurp next line and try again
|
# otherwise, slurp next line and try again
|
||||||
N
|
N
|
||||||
s/\n//
|
s/\n//
|
||||||
bsqstring
|
bsqstr
|
||||||
:sqdone
|
:sqdone
|
||||||
s/@!/'/g
|
s/@!/'/g
|
||||||
bfolded
|
bfolded
|
||||||
|
@ -282,11 +282,11 @@ bfolded
|
||||||
:heredoc
|
:heredoc
|
||||||
s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
|
s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
|
||||||
s/[ ]*<<//
|
s/[ ]*<<//
|
||||||
:heredsub
|
:hdocsub
|
||||||
N
|
N
|
||||||
/^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{
|
/^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{
|
||||||
s/\n.*$//
|
s/\n.*$//
|
||||||
bheredsub
|
bhdocsub
|
||||||
}
|
}
|
||||||
s/^<[^>]*>//
|
s/^<[^>]*>//
|
||||||
s/\n.*$//
|
s/\n.*$//
|
||||||
|
@ -305,7 +305,7 @@ bcase
|
||||||
x
|
x
|
||||||
s/?!AMP?!//
|
s/?!AMP?!//
|
||||||
x
|
x
|
||||||
bcontinue
|
bcont
|
||||||
|
|
||||||
# found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
|
# found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
|
||||||
# "suspect" from final contained line since that line legitimately lacks "&&"
|
# "suspect" from final contained line since that line legitimately lacks "&&"
|
||||||
|
@ -321,10 +321,10 @@ bchkchn
|
||||||
# found nested multi-line "(...\n...)" -- pass through untouched
|
# found nested multi-line "(...\n...)" -- pass through untouched
|
||||||
:nest
|
:nest
|
||||||
x
|
x
|
||||||
:nstslurp
|
:nstslrp
|
||||||
n
|
n
|
||||||
# closing ")" on own line -- stop nested slurp
|
# closing ")" on own line -- stop nested slurp
|
||||||
/^[ ]*)/bnstclose
|
/^[ ]*)/bnstcl
|
||||||
# comment -- not closing ")" if in comment
|
# comment -- not closing ")" if in comment
|
||||||
/^[ ]*#/bnstcnt
|
/^[ ]*#/bnstcnt
|
||||||
# "$((...))" -- arithmetic expansion; not closing ")"
|
# "$((...))" -- arithmetic expansion; not closing ")"
|
||||||
|
@ -332,11 +332,11 @@ n
|
||||||
# "$(...)" -- command substitution; not closing ")"
|
# "$(...)" -- command substitution; not closing ")"
|
||||||
/\$([^)][^)]*)[^)]*$/bnstcnt
|
/\$([^)][^)]*)[^)]*$/bnstcnt
|
||||||
# closing "...)" -- stop nested slurp
|
# closing "...)" -- stop nested slurp
|
||||||
/)/bnstclose
|
/)/bnstcl
|
||||||
:nstcnt
|
:nstcnt
|
||||||
x
|
x
|
||||||
bnstslurp
|
bnstslrp
|
||||||
:nstclose
|
:nstcl
|
||||||
s/^/>>/
|
s/^/>>/
|
||||||
# is it "))" which closes nested and parent subshells?
|
# is it "))" which closes nested and parent subshells?
|
||||||
/)[ ]*)/bslurp
|
/)[ ]*)/bslurp
|
||||||
|
|
Loading…
Reference in New Issue