Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (4) </ 1 [2] 3 4 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Cond statements, BASH< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Sep. 09 2007,02:56 QUOTE

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


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
jpeters Offline





Group: Members
Posts: 804
Joined: April 2006
Posted: Sep. 09 2007,03:18 QUOTE

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 ) ???
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Sep. 09 2007,13:43 QUOTE

"[" 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

--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Sep. 09 2007,15:14 QUOTE

actually [ is an alias for test..

--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Sep. 09 2007,15:39 QUOTE

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.
Back to top
Profile PM 
15 replies since Sep. 08 2007,19:00 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (4) </ 1 [2] 3 4 >/
reply to topic new topic new poll
Quick Reply: Cond statements, BASH

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code