Hacker News new | ask | show | jobs
by ftaghn 1048 days ago
> I always expected to become fluent in bash at some point, but the AI became too good at writing my scripts now...

This page :

https://mywiki.wooledge.org/BashPitfalls

Is the fastest way of becoming proficient with shell scripting. Whether it's pure posix shell, or bash and its extensions, they're small languages and can be learned in a week end if you're proficient in another programming language. The main pain point is that there's a lot of "surprises" and non-intuitive behaviors, that are all listed here. The first ones, about parameter expansions, quoting variables and leading dashes are the most common issue with newbies in shell scripting.

There's a lot of amazing tooling these days to make sure your shell scripts are fine too. First, shellcheck:

https://www.shellcheck.net/

I systematically run this on my scripts before using them.

Then shfmt for nice, reliable autoformatting: https://github.com/mvdan/sh

And finally, checkbashisms if you intend on making pure posix scripts that are compatible with debian/ubuntu's dash. It is part of the debian's devscripts suite, but is often individually packaged in other distros.

> Also you can use the chat as a learning tool

Or you could learn from a guide written by people who have suffered decades of experience of the pitfalls of shell scripting and have shared their woes.

https://mywiki.wooledge.org/BashGuide

chatGPT is good at coming up with magical solutions, but teaching you about all the corner cases?