Re:I Accidentally Deleted 7TB of Videos Before Going to Prod...
by ufo on Thursday May 05, 2022 @11:50AM
(#31274902)
Do you mean, always pass the list directly to the next script via function calls, without writing it to an intermediate file / pipeline?
[ Parent
| on HN ]
Re:I Accidentally Deleted 7TB of Videos Before Going to Prod...
by kevinmgranger on Friday May 06, 2022 @12:02PM
(#31286752)
I'm being flippant, because shell scripts are so inherently error prone they're to be avoided for critical stuff like this.
If you _absolutely_ must use a shell script:
0. Use shellcheck, which will warn you about many of the below issues: https://www.shellcheck.net/
1. understand how quoting and word splitting work: https://mywiki.wooledge.org/Quotes
2. if piping files to other programs, using `-print0` or equivalent (or even better, if using something like find, its built in execution options): https://mywiki.wooledge.org/UsingFind
3. Beware the pitfalls (especially something like parsing `ls`): https://mywiki.wooledge.org/BashPitfalls
(warning: the community around that wiki can be pretty toxic, just keep that in mind when foraying into it.)