Other Help Topics :: Cond statements, BASH



I think there's something screwy with your bash.

Are you using #!/bin/sh as an interpreter instead of #!/bin/bash? I've read that Bash behaves differently if it's called as sh

Quote (mikshaw @ Sep. 08 2007,22:56)
I think there's something screwy with your bash.

Are you using #!/bin/sh as an interpreter instead of #!/bin/bash? I've read that Bash behaves differently if it's called as sh

Same result using /bin/sh (as /bin/bash).  I've tried it on two computers with the same results.

EDIT: I just compiled BASH 3.2, and got the same results! Now I'm really baffled.

EDIT2:  Okay; got it working.  Problem was that there needs to be a space before and after the brackets:  if [   3 -eq 3   ]
(I put in several, just to make sure...it's hard to see single spaces in print ) ???

"[" is a command, just as "test" is a command. If you think about it that way it might not even occur to you to _not_ include the spaces. After all, you wouldn't use the test command this way: if test23 == 23
actually [ is an alias for test..
If you really want to be technical, I think [ and test are separate binaries (different invokes I suppose - though I guess busybox would have all symlinks directing back to it)

Quote
(I put in several, just to make sure...it's hard to see single spaces in print )
I like to have an electronic source as well for learning things like this, due to an easy copy and paste, or zoom.

Next Page...
original here.