match_parens(1) | DekDoc scripts | match_parens(1) |
NAME
match_parens - find mismatches of various brackets and quotes
Synopsis
match_parens [filename]
Options
-h
Description
Mismatches of parentheses, braces, (angle) brackets, especially in TeX sources which may be rich in those, may be difficult to trace. This little script helps you by writing your text to standard output, after adding a left margin to your text, which will normally be almost empty, but will clearly show up to 10 mismatches. (Just try me on myself to see that the parenthesis starting this sentence will not appear to be matched at the end of the file. If you look at me in the vim editor, then select this paragraph and try the command: :!%.
By default, the following pairs are tested:
()
The exit value of the script is 0 when there are no mismatches, 1 otherwise.
Angle brackets are only looked for inside HTML text, where HTML is supposed to start with <html> or =begin␣rdoc and to end with </html> or =end.
Options
-h,--help
Examples
Suppose we have two files, good and bad, containing these texts:
good:
bad:
then here are some usage examples. First a simple test on these
files: $ matchparens good
1 || This is a (simple) test
2 || without mismatches
$ echo $?
0
$ matchparens bad
1 | (| This is a (simple test
2 | (| containing mismatches
$ echo $?
1
Just report if there are mismatches: $ matchparens good
>/dev/null && echo fine || echo problems
fine
$ matchparens bad >/dev/null && echo fine || echo problems
problems
Report all tex files with mismatches in the current directory: $ for i in *.tex; do matchparens $i >/dev/null || echo $i; done
Matches must be in correct order: $ echo -e "This is a
([simple)] test0 | match_parens
1 ([)]This is a ([simple)] test
2 ([)]
Author
Wybo Dekker (wybo@dekkerdocumenten.nl)
Copyright
Released under the GNU General Public License (www.gnu.orgcopyleftgpl.html)
March 23, 2023 | match_parens version 1.44 |