News for hackers. Stuff that matters.
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by j1elo on Thursday December 30, 2021 @05:58AM (#29735659)
I guess this is as good of a time as any other to remind people to use the "unofficial" Bash strict mode:

https://gist.github.com/robin-a-meade/58d60124b88b60816e8349... [^1]

And always, always, use ShellCheck (https://www.shellcheck.net/) to catch most pitfalls and common mistakes on this powerful but dangerous language that is shell scripting.

[^1]: I think this gist is better than the original article in which it is based, because the article also suggested changing the IFS variable, which is not that good of an advice, so sadly the original text becomes a bad recommendation!

Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by xvilka on Thursday December 30, 2021 @08:15AM (#29736449)
And don't use shell for writing complex scripts, there are better automation tools and languages.
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by j1elo on Thursday December 30, 2021 @11:14AM (#29737925)
Good point, except if an important part of your complex script is really just plumbing the outputs of one program to the inputs of another. Because that's what shell scripting excels at. Calling an external process is a first-class citizen in shell, whereas it is a somewhat clunky thing (or at the very least, much more verbose) to do in any other languages.
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by tryauuum on Thursday December 30, 2021 @06:27PM (#29742847)
I'd say that as long as bash script fits on a single screen you won't get any benefit from switching to some other tool or language
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by rrll22 on Thursday December 30, 2021 @09:27AM (#29736929)
Such as?
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by dqpb on Thursday December 30, 2021 @10:01AM (#29737217)
Python
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by BeatQuestGames on Thursday December 30, 2021 @10:43AM (#29737628)
For example,take my project.

https://github.com/Mylab6/PiBluetoothMidSetup

While I could of done this in Bash.

1. I don't really like Bash

2. Python is much easier. I did challenge myself to only use Python's built in libraries, but aside from being unable to use Yaml everything works.

I can imagine in some environments you might not have access to a Python interrupter though...

Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by thaumasiotes on Thursday December 30, 2021 @07:35AM (#29736210)
> I guess this is as good of a time as any other to remind people to use the "unofficial" Bash strict mode

Not really; the report doesn't mention any error in the script.

Re:Japan HP accidentally deleted 77TB data in Kyoto U. super... by leoh on Thursday December 30, 2021 @08:02AM (#29736362)
There is a reading which suggests that an environment variable being unset caused an overabundance of files being deleted. `set -u` causes the script to exit if any variables are unset.