Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Bitwise ops in a conditional



This should be fairly simple, but I missed something.

I want to test if a shell variable is odd or not in a conditional to generate a simple odd/even testing which seems natural to me.  

I did the below:

	  if [[ ((index & 0x01)) .eq 1 ]]  then
	    print "odd index processing"
	  else
	    print "even index processing
	  fi


Actually I thought that a simple
		 if [[ index & 0x01 ]] should work, but conditionaly may requie 2 args?

Any suggestions of using binary operators in conditions would be appreciated.


Thanks,
  Darel Henman



Messages sorted by: Reverse Date, Date, Thread, Author