News for hackers. Stuff that matters.
Re:An almost perfect rsync over SSH backup script by senko on Friday February 25, 2022 @11:04AM (#30468700)
Agreed on fail on error, but the first one is needlessly pedantic.

Find me a single Linux distro where bash, if installed, is not available in /bin

Re:An almost perfect rsync over SSH backup script by jethro_tell on Friday February 25, 2022 @02:08PM (#30470901)
As a system eng for almost 15 years I've spent a good number of years handling deployments, dependancies, environment evaluations and all the little minutiae that's required to run large complex distributed systems at scale. This is fine to ignore if it's your personal box and no one else is working on it.

However I've seen it happen quite frequently in systems that were designed with container like 'chroot-lite' prod setups where the system bash and the deployed environment may contain different bash.

The different bash is the one that was tested in the test env with the automation. There may even be multiple different versions of an interpreter on the system with multiple app environments running.

This was a pretty common way to package apps before easy access to containers and container managers.

This is why we have industry best practices, so that people who don't understand why something exists can just follow the best practices and we don't all have to be experts in things outside of our direct field.

Re:An almost perfect rsync over SSH backup script by scottlamb on Friday February 25, 2022 @04:34PM (#30472634)
> This is why we have industry best practices, so that people who don't understand why something exists can just follow the best practices and we don't all have to be experts in things outside of our direct field.

We don't have industry best practices for shell scripts, no matter what consultants / HN commenters with strong opinions say. You can see in this thread that folks disagree about what the best practices are. It's worth paying attention to folks' rationale for their opinions—I learned some caveats about "-e" from following the links here. But the talk about "table stakes" and "industry best practices" is (extended bleep). Those don't exist.

Different projects/companies may have their own best practice guides that make sense in their environment. senko mentioned Google data centers as a place where it might make sense to be more rigorous. Google's guide says to use "#!/bin/bash". [1] If that doesn't work in your environment, fine, but that doesn't make them wrong.

Shell is a surprisingly and unnecessarily difficult language to write correctly. To the extent there is a best practice on it, I think it's "use a better language for anything that might become large or important". The Google style guide I linked says more or less the same thing near the beginning. The subtleties discussed in the rest give you a taste of why...

[1] https://google.github.io/styleguide/shellguide.html

Re:An almost perfect rsync over SSH backup script by senko on Friday February 25, 2022 @03:09PM (#30471756)
I was a sysadmin on SunOS, HP/UX and BSD systems back in the day and have been maintaining various Linux-based systems in the past few decades as well.

We're not talking about Google data center here, it's just someone's shell script.

Re:An almost perfect rsync over SSH backup script by bobbyi on Friday February 25, 2022 @03:40PM (#30472095)
On my laptop (admittedly, it's running Mac OS, not a linux distro), /bin/bash is version 3.2.57 released in 2007, while '/usr/bin/env bash' invokes bash 5.1.8, released in 2020.
Re:An almost perfect rsync over SSH backup script by pkulak on Friday February 25, 2022 @11:40AM (#30469138)
I'd argue it's easier to find a distro without /usr/bin/env.
Re:An almost perfect rsync over SSH backup script by zeec123 on Friday February 25, 2022 @12:13PM (#30469535)
NixOS
Re:An almost perfect rsync over SSH backup script by aidenn0 on Friday February 25, 2022 @02:40PM (#30471359)
1. bash runs on more than just linux

2. Many non-LSB distros

Re:An almost perfect rsync over SSH backup script by senko on Friday February 25, 2022 @03:05PM (#30471720)
The article talks about Linux.
Re:An almost perfect rsync over SSH backup script by mekster on Saturday February 26, 2022 @07:41PM (#30483964)
There are more than Linux in the real world.