logical XOR

2007-06-13 Thread ackstorm
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2
uname output: Linux acklap03 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 
i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.1
Patch Level: 17
Release Status: release

Description:
There's bitwise AND and bitwise OR, and logical AND and logical OR, but
for XOR there's only the bitwise version.  Would be nice if the logical
XOR would also be present (^^).

Repeat-By:
[Describe the sequence of events that causes the problem
to occur.]

Fix:
If you like the idea I can send a patch.


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


Re: logical XOR

2007-06-29 Thread Robert Millan [ackstorm]
On Thu, Jun 28, 2007 at 06:58:25PM -0400, Chet Ramey wrote:
> ackstorm wrote:
> > Configuration Information [Automatically generated, do not change]:
> > Machine: i486
> > OS: linux-gnu
> > Compiler: gcc
> > Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
> > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
> > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> > -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2
> > uname output: Linux acklap03 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 
> > 2007 i686 GNU/Linux
> > Machine Type: i486-pc-linux-gnu
> > 
> > Bash Version: 3.1
> > Patch Level: 17
> > Release Status: release
> > 
> > Description:
> > There's bitwise AND and bitwise OR, and logical AND and logical OR, but
> > for XOR there's only the bitwise version.  Would be nice if the logical
> > XOR would also be present (^^).
> 
> (!a) != (!b)
> 
> should work acceptably for the situations such an operator would be used.

I'm not sure what you mean.  The following:

(true && ! false) || (false && ! true)
echo $?

works, whereas the following:

(! true) != (! false)
echo $?

shows syntax error.

Is there any way to avoid redundancy in the shell script that needs this?  The
code in question is already quite complex, so adding this redundancy makes it
less readable.

> The reason it's not there is because it's not in C.

Because of performance?

-- 
Robert Millan


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


Re: logical XOR

2007-06-29 Thread Robert Millan [ackstorm]
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.

-- 
Robert Millan


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