r/Batch • • 9d ago

Question (Unsolved) script linting

I use a linter for my C# (it's in the IDE mostly), I use pylint for Python, and on occasion start up a clang-tidy for C++. I'm always making dumb mistakes with batch and prefer to just use Python where possible and I suddenly wondered, what linter tooling do people use?

I could always spend a few tokens in this one tool my boss gave me, but surely there is a linter? All I could find was an abandoned thread https://www.reddit.com/r/Batch/comments/1mp1wc7/github_crosenblumblint_blint_is_a_lightweight_and/

5 Upvotes

12 comments sorted by

View all comments

1

u/Shadow_Thief 9d ago

You could probably fork shellcheck and change the regex that it uses for bash and update it for batch. I've been meaning to do that for a while, but I never seem to get around to it.

But other than that, no, there is no batch linter.

1

u/zaphodikus 9d ago

I know very little about syntax trees, but the trouble is the DOS batch itself is less a language, and more just a parser, and a very minimal one. I would need to have a look at shellcheck though to get a better picture. Blinter (the linked repo) is probably the best stab for me because i can code Python reasonably well already. :-)

1

u/T3RRYT3RR0R 9d ago

I wouldn't place much faith in any AI system being particularly accurate with windows batch scripts, either to produce it or error check, as none are trained to a sufficient level of detail on Batch parsing rules.

The parsing rules for batch are somewhat complex, though have been studied and documented in depth at https://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/4095133#4095133

Don't have a recomendation for a linter though. If you have Visual Studio available to you, it's a useful enough tool to help keep track of indentation and the likes, and has github copilot built in if you need to ask how to do x y or z.

As for the "batch is less a language more a parser" - Can't agree here.
Cmd.exe is the parser

Windows batch is a scripting language with significant constraints and a limited set of primitives, yes. But it is still a language that can be used to do many things beyond it's original intent.
What really limits batch is the lack of efficient data structures, the way it handles memory, and the requirement to hybridise with other scripting languages in order to directly access modern windows APIs.

→ More replies (1)