On Saturday 15 November 2008 11:42, David C. Rankin wrote:
Randall R Schulz wrote:
On Friday 14 November 2008 20:54, David C. Rankin wrote:
Listmates,
Stuck on a stupid bash problem again. ...
What Jim Cunning said is correct.
However, there is another similar kind of command grouping syntax that does not cause the creation of a sub-shell: the { curly brace }. Side-effect on local variables and shell options made within this construct _do_ persist outside / beyond it.
-- David C. Rankin
Randall Schulz
Randall,
I will have to try that again. I thought something similar to brace expansion was correct, like awk '{ do this/that }', but the last time I tried (and I tried a lot), BASH kept complaining about my syntax (not a uncommon happening), I'll give it another go.
For whatever reason, if the closing brace is on the same line as the final command it encloses, you must end that command with a semicolon. This is not the case with parentheses.
My desire for one-liners for simple tests is to cut down on the amount of scrolling I have to do while editing which for me makes the script more readable. If I can reduce two pages of "does this variable exist"" "is it defined?" "is the file writable?"... to 5 lines, then I simply have a small test block that precedes the actual logic of the script instead of two pages of simple tests.
If you're worried about using undefined variables, there's an option that turns such references into errors (rather than the default empty substitution). % unset foo % echo $foo is bar is bar % set -u % echo $foo is bar bash: foo: unbound variable % set +u % echo $foo is bar is bar
......
-- David C. Rankin
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org