On Fri, Jun 29, 2007 at 12:08:22PM +0200, Robert Millan [ackstorm] wrote:
> On Fri, Jun 29, 2007 at 10:16:18AM +0100, Stephane Chazelas wrote:
> > 
> > Do you mean that for instance, you'd like a third command to be
> > executed if either but not both of two commands succeed?
> > 
> > cmd1; a=$?
> > cmd2; b=$?
> > (( !a != !b )) && cmd3
> > 
> > should do.
> 
> Thank you, that works.  Although I think ^^ would be more intuitive.  Let me
> know if you want a patch for that.
[...]

You could do something like:

xor() {
  previous_status=$?
  "$@"
  return "$((!$previous_status == !$?))"
}

cmd1; xor cmd2 && cmd3

-- 
Stéphane


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to