Skip to main content
8 events
when toggle format what by license comment
Sep 12, 2023 at 10:48 comment added galaxis The examples make the better answer.
May 18, 2023 at 22:54 comment added Jemenake The part about braces being keywords is important. It's what allows you to do things like: { task1 && task2 && task3 && echo "Success!"; } || { echo "One of the tasks failed!"; exit 1; } in a larger script. If you use parentheses, exit 1 will just exit out of a subshell and any surrounding script will keep running. Without the ending semicolon in each set of braces, you'll get "Unexpected end of file".
Nov 30, 2017 at 15:25 comment added Stéphane Chazelas Note that it's [[ -L $file && -f $file ]] (no -a with the [[...]] variant).
Nov 30, 2017 at 15:22 history edited Stéphane Chazelas CC BY-SA 3.0
a few additions, fixes and clarifications
Apr 13, 2017 at 12:36 history edited CommunityBot
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Aug 27, 2016 at 23:38 comment added Gilles 'SO- stop being evil' @AlexisWilke The operators -a and -o are problematic because they can lead to incorrect parses if some of the operands involved look like operators. That's why I don't mention them: they have zero advantage and don't always work. And never write unquoted variable expansions without a good reason: [[ -L $file -a -f $file ]] is fine but with single brackets you need [ -L "$file" -a -f "$file" ] (which is ok e.g. if $file always starts with / or ./).
Aug 27, 2016 at 23:34 comment added Alexis Wilke Note that single bracket supports the -a instead of &&, so one can write: [ -L $file -a -f $file ], which is the same number of characters within the brackets without the extra [ and ]...
Aug 27, 2016 at 22:45 history answered Gilles 'SO- stop being evil' CC BY-SA 3.0