881 reputation
39
bio website mad-scientist.net
location
age
visits member for 1 year, 2 months
seen Apr 25 at 14:22
stats profile views 14

Mar
19
answered How to print “$” in here-document
Mar
19
comment Is it possible to use indirection for setting variables?
This (using eval) is the correct answer. It's portable, adheres to the POSIX standard, and is the one used all over the place in more advanced shell scripts. One thing, though: using export on the same line as the assignment is not portable.
Mar
10
awarded  Yearling
Feb
22
awarded  Commentator
Feb
22
awarded  Scholar
Feb
22
awarded  Supporter
Feb
22
comment Why does the local::lib shell code use eval and $()
It's probably simplest to understand if you just run the command inside the $() and look at what it prints. That's what the shell will eval. Just to be clear, $() is the new-fangled way of writing backticks (command interpolation)... it's nice because it's easily nestable. Otherwise there's not much difference.
Feb
22
comment Why does set -e not work inside () ||
You're right; I'm not sure how I misread those. Thanks.
Feb
22
accepted Why does set -e not work inside () ||
Feb
21
comment Why does set -e not work inside () ||
Well, if all the shells behave that way it's by definition not a bug... it's standard behavior :-). We may lament the behavior as non-intuitive but... The trick with eval is very interesting, that's for sure.
Feb
21
comment Why does set -e not work inside () ||
Thanks for those links, they were very interesting. However, my example is (IMO) substantively different. Most of that discussion is whether set -e in a parent shell is inherited by the subshell: set -e; (false; echo passed;) || echo failed. It does not surprise me, actually, that -e is ignored in this case given the wording of the standard. In my case, though, I'm explicitly setting -e in the subshell, and expecting the subshell to exit on failure. There's no AND-OR list in the subshell...
Feb
20
awarded  Student
Feb
20
asked Why does set -e not work inside () ||
Jul
21
comment .DELETE_ON_ERROR behavior with make and pipelines
Please do not do this. It will fail on any system where /bin/sh != bash, which are quite a few systems (all Ubuntu and Debian versions of Linux, and almost every non-Linux system). If you want bash behavior, you should always request bash specifically: /bin/bash -e -o pipefail
Jun
11
comment Change directory with space followed by '('
At some point backslashes become more of a problem than they're worth. If you have more than one or two special characters it's simpler to quote the entire file name; either "Program Files (x86)" or 'Program Files (x86)' will work.
May
31
answered How to generate new var names on the fly
May
27
answered Why `> my.log 2>&1 &` causes the job to sustain log out?
May
22
answered Interactive commands in Bash functions
May
5
awarded  Enlightened
May
5
awarded  Nice Answer