echo 'I wrote a Bash book' >> /dev/world
paperless.blog
paperless.blog
Chances are, it isn't.
https://mywiki.wooledge.org/BashGuide
https://mywiki.wooledge.org/FullBashGuide
Because that is a pretty amazing resource.
- It is more relevant for scripting than the interactive command line. For example, it includes
- I've taken a lot of care to write non-trivial example code, which is useful to show when and where constructs are useful, and which other constructs they are usually used with. For example, the argument parsing part shows not just how to use `getopt`, but also how it's meant to be used with `eval`, `unset`, `while`, `case`, and `shift`; the standard `--` option/argument separator; how to handle unimplemented options (anything mentioned by `getopt` but not matched by any `case` statements); and how to deal with the remaining arguments.
- The non-trivial code has been linted using `shellcheck` and a lot of it is tested with `shunit2` (533 lines of tests in total, which are included as a download).
It's cool, people need such stuff but the title is misleading and the article is basically an ad for a paid service.
It's clearly a course - 99 lessons, wow! First look at the index may confuse potential reader. It's about signals and copy and paste at the same time. Copy and paste actually CAN be tricky and is mostly not well understood for people not raised on a Linux desktop. But the headline itself confuses me and my first though was that it's more of a beginner course like those RedHat has at the begging of the certification path, before tests start. - what is console, what is Gnome, files, users, groups etc..
What usually made me interested in such products was a clear, full chapter that I can read. Even better if it's an actual chapter that can be used individually, without the context of the rest of the book. Not the introduction. It is usable on it's own, so it's linked by people - that is some good publicity. It worked on me and some of my friends!
Also how does it compare to other books, like https://tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Gui...? Yours looks like for beginners but it's just targeted towards devs that don't know bash and linux terminal well. The linked one is titles "for beginners" but it's not really :)
I hope this gives you some insight that you can use in future. I really didn't wanted to just complain in vain. Some of my friends wrote large IT books and I know how weird experience it is to work with a publisher. Good look!
I haven't read the guide you linked to, but scanning the index I'd say my book is quite different:
- A big portion of my book is about quality assurance - exiting early, automated testing, linting, the most readable forms of commands, and the like.
- It's focused much more on scripting than command-line use.
- It avoids common pitfalls like using `which` to determine what will be run[2].
- Rather than give a surface treatment of `sed` and `awk` it treats those as separate subjects which would be better learned from some other source. Personally I avoid `sed` and `awk` in scripts where possible, since a lot of the things they do can be achieved with more maintainable commands, anything non-trivial is really hard to read, and using either is an indication that the problem might better be implemented in another language.
- It's opinionated about interactive scripts. Basically I consider them a bad idea the vast majority of the time because they pretty much preclude wrapping in a sensible way, and add a bunch of extra code irrelevant to solving the problem.
[1] https://victor-engmark.gitlab.io/advanced-shell-scripting-wi...
Can you elaborate on that? I'm sure it's both true and false depending on your definition of "how and where it is run," but wondering what you had in mind specifically.
A container is basically a "virtualenv" for shell, and it's honestly better than that because:
- it's more general (it isolates every language, not just Python), and
- not even bigger (e.g. an Alpine Linux container is not that much bigger than the Python install in every virtualenv!)
Traditionally you do indeed have the problem that copying a shell script from one machine to another basically guarantees you nothing about how it will work. These days we deploy containers, which solve the problem, and that's why shell is used so much in the cloud (e.g. anything with Github Actions has a boatload of shell)
Even more on that: https://www.oilshell.org/blog/2021/07/cloud-review.html
Although there is the "empty elision" case related to splitting: if x='', then $x is different than "$x", even if IFS=''.
You could also use zsh which doesn't do word splitting, but does "empty elision". (I'd say zsh is a better interactive shell than a scripting language, but I've seen it used on occasion.)
Or you can use OSH, which will run your bash script as is. And then you can opt into shopt -s simple_word_eval or the group shopt -s oil:basic, and EVERYTHING will be "unmolested", quotes or not:
cp $FILENAME $TARGET
Write this: cp "$FILENAME" "$TARGET"
It's a bit annoying, but it's not that bad, and certainly not unmaintainable. find . -name "*.csv" -print | while IFS= read -r file; do
doneAlways. Be. Quoting.
Also, you should be checking your Bash scripts with shellcheck, which will tell you when to do this with ~99% accuracy.
(For the uninitiated: https://www.youtube.com/watch?v=GrhSLf0I-HM)
I'd like to write a follow-up article about the process of getting there if there's any interest. AMA.