You are not logged in.
I have two variables in a script: $a and $b
They are set to either "y" or "n" by the user - I need a conditional to break the script if the users sets them both to "y"
This doesn't work but you get the idea:
if [ $a = "y" && $b = "y" ]; then
exit
fi
What is the right syntax to accomplish this? The other three combinations are fine (nn, ny, and yn).
Last edited by graysky (2010-10-09 21:33:05)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Online
man test:
if [ "x$a" = "xy" -a "x$b" = "xy" ]; then
exit
fi
Edit: the "x" before the variables is to ensure nothing funny happens if the variables haven't been asigned.
Last edited by olvar (2010-10-09 20:21:55)
Offline
http://mywiki.wooledge.org/BashPitfalls … 3D_foo_.5D
@ olvar https://bbs.archlinux.org/viewtopic.php … 95#p833995
Last edited by karol (2010-10-09 20:34:40)
Offline
Thanks olvar and karol - very informative link in that wiki.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Online
Oops... sorry for promoting my bad habits
Offline