I originally meant to post a quick tip, but then I yammered at the end--Dave Barry calls this "blitherer's disease."
Note to those who just found this thread: I was only curious about the superfluous problem. Feel free to solve it, but there are others who actually need help.
My script is working and in place. That said, I love seeing my superiors' smarter code.
bigearsbilly, thanks for posting that. I'm evidently too impaired to realize escaping also works
inside a test. I started by attempting to group the args, because I once read about problems controlling precedence with "-a" and "-o"--guess that guy was wrong.
unSpawn, thanks as well. Your "binary" code is a great idea, and tweaking it to do what I meant (not what I said ;-) was a snap.
I wasn't clear; by "both," I meant both tests from my first post. I just wondered if it's possible to do all this in a single test:
Code:
( ([a=1] -o [b=2 -a c=3]) but not ([a=1] -a [b=2 -a c=3]) )
This worked:
Code:
#!/bin/sh
res=0; read a b c
[ "$a" = "1" ] && res=$[$res+1]
[ "$b" = "2" -a "$c" = "3" ] && res=$[$res+2]
case "$res" in 1|2) echo \
"yep";; *) echo "nope";; esac
(10:37:07 bin) ./werks
5 5 5 <- neither
nope
(10:37:19 bin) ./werks
5 2 3 <- 2nd
yep
(10:37:23 bin) ./werks
1 4 4 <- 1st
yep
(10:37:30 bin) ./werks
1 2 3 <- both
nope