3 ms·
I feel the same way about "advanced" shell scripting techniques as I do about "cutting-edge" accounting techniques: someone's probably going to jail. I have wr
by jake_morrison 3y ago
I feel the same way about "advanced" shell scripting techniques as I do about "cutting-edge" accounting techniques: someone's probably going to jail.
I have written some big complex systems in shell and regretted it.
My rule of thumb is that if a script needs error handling, it's time to write it in a real programming language. Tricky shell programs running as root are a real danger.
It's nice to know that some of these techniques exist, but better not to use them. Many of them have to do with string manipulation, which is a sign that a proper language with data structures would be a win.
Many people don't realize that perl is part of the Debian base system. If you are going to go crazy with one-liners, then that's a better tool. I would generally recommend Python, though.
Avoiding bash-isms is useful so that you can run under busybox shell, reducing the size and dependencies of containers.
Embedded systems often use shell. If you are tempted to install bash for more power, a better solution is probably lua. It's smaller and saner.