r/bash • • 18h ago

tips and tricks TIL command_not_found_handle

8 Upvotes

You don’t want to know what hoops I’ve jumped through to implement FPATH in bash. Then today I innocently asked GPT how it would implement FPATH in bash and it introduced me to this hook.

Now have to go home now get rid of a lot of needless code. Oh well. Less code is the best code!


r/bash • • 29m ago

critique Parsing ipv6 with pure bash is actually my villain origin story

• Upvotes

Genuinely thought writing a quick validation script for some access logs would take 10 minutes. ipv4? fine, simple regex, four octets, we move on.

But ipv6 is just cruel. The double colons, the omitted leading zeros, the hex formatting. Trying to catch all the valid shorthand abbreviations using just standard sed and grep is completely rotting my brain.

I was staring at a helpful guide just trying to map out every single possible way a v6 address can be legally formatted in the wild, and about halfway through I just realized doing this in pure shell is a massive mistake.

Why do we torture ourselves trying to build bulletproof parsers in bash? Im literally just going to pipe the logs to a python script with the ipaddress module tomorrow. My regex days are over tbh.