On Wed, Nov 9, 2011 at 10:09 PM, Sebastian Schwarz <[email protected]> wrote: > On 2011-11-08 at 21:56 -0800, Linus Arver wrote: >> Some vcs prototypes do >> >> cd repo && update >> >> while others do it like >> >> cd repo >> update >> >> to update an existing repo. It makes sense to have them all do it the >> first way (there's nothing wrong with it, and it has better form). > > I agree with the consistency issue, but not with using the first > way. makepkg is executed with `/bin/bash -e`[1]. Whenever > a command returns a non zero exit status makepkg exits > immediately. See bash(1) or set(1p). Thus conditional checks > on single commands with && and || are seldomly required[2].
Actually, with `set -e', the second form is safer. In the first form, if `cd repo' fails, bash will NOT abort. This is the relevant part in bash(1) on `set -e': The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test following the if or elif reserved words, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !. So yes, the `&&' form is totally busted. > Even in the second case the "update" step is never reached. > > I personally find the second form easier to read, as one does > not have to think about why the && was mixed in, and if this > makes sense. > > [1]: > http://projects.archlinux.org/pacman.git/commit/?id=b69edc1c3532816576198995675dd6ad53df74df > [2]: > http://projects.archlinux.org/pacman.git/commit/?id=2710b256cc260db6a0805c83fb3fcf9e32aa3d86 >
