checkbrack(1)

πŸ“¦
this version Β· 3 versions
, in nixos 26.05, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’… checkbrack(1)

okay so bestie, this little icon lives in hxtools and she is literally the friend who tells you where your brackets went missing. no cap, she's a lifesaver. let's get into it 🫢


🌸 NAME 🌸

checkbrack β€” check parenthesis and bracket count ✨

πŸŽ€ SYNTAX πŸŽ€

checkbrack file...

πŸ¦‹ DESCRIPTION πŸ¦‹

So what she does is: she displays each line of the file(s) β€” yes, plural, you can feed her more than one β€” together with their open bracket count that is reached at the end of that line. πŸ’–

Like, especially, she lets you find missing closing brackets. and ngl that is so helpful, because the Perl interpreter for example has problems telling you where exactly something went wrong 😭 like it'll just yell at you with no location and you're standing there like ??? bestie where. checkbrack knows where. πŸ‘‘

⭐ EXAMPLE ⭐

$ checkbrack /usr/lib/hxtools/bin/checkbrack | less -S
#   () [] {}
13  0  0  1 foreach my $file (@ARGV) {
14  0  0  1     if (!-f $file) { next; }
15  0  0  1     print "Displaying $file...0;
16  0  0  2     if (!open(IN, "< $file")) {
17  0  0  2         print "Error opening $file: $!0;
18  0  0  2         next;
19  0  0  1     }

so the numbers at the front are, in order: line number, number of unclosed left parentheses, number of unclosed left square brackets and number of unclosed left square braces. four little columns of truth πŸ’…

and look at the end of line 19 β€” we would need to close one more brace to make it syntactically valid code. one. more. brace. 😭 she's telling you!! listen to her!!

the interesting thing of this (fr fr the main character move) is that if GCC, Perl or whatever outputs an error and you do not figure out what it means β€” and that is often the case with missing braces, no shade β€” just run checkbrack on the source file, skip to the end, and watch the brace counts. πŸ‘€

then scroll up until the brace counts seem normal (i.e. 0 open braces) at outside any function. that's it. that's the whole trick. slay. 🧚

lowkey the vibe check here is: counts going up as you go deeper = fine, counts not coming back down = your bracket is lost in the wilderness πŸ™ˆ

🌈 SEE ALSO 🌈

hxtools(7) β€” go read the whole family, iykyk πŸ’œ


and that's the page bestie!! brought to you by hxtools, dated 2008-02-06 β€” she's been iconic since day one and she's still serving πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from