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 >
curaga Offline





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

Or even more tech: both [ and test are actually the same common shell builtin, atleast bash and ash have it. So when invoked just like that, [ something or test something, they are the same thing, but as binaries, /usr/bin/[ something, they would be different ;)

--------------
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 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Sep. 09 2007,16:22 QUOTE

When struggling with bash syntax it is often helpful to preuse existing bash scripts, i.e., /etc/init.d/knoppix-autoconfig and/or /etc/init.d/dsl.config
Back to top
Profile PM WEB 
jpeters Offline





Group: Members
Posts: 804
Joined: April 2006
Posted: Sep. 09 2007,21:34 QUOTE

I'm always impressed by the level of expertise on this board.  Although I'm not sure where someone learns about binaries related to
"[" vs. "test" , I'm duly impressed and enlightened.  I'm studying knoppix-autoconfig right now with vim, where spacing is clear.
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Sep. 09 2007,23:37 QUOTE

Quote
Although I'm not sure where someone learns about binaries related to
"[" vs. "test"
I can't speak for others, but in my case it comes from constant poking and prodding at things to see what color they bleed.

When it comes to "[" specifically, I just thought it was very odd to see that character listed as a filename when i did "ls /usr/bin", so I had to find out what was up.  This is kind of an unusual situation because "man [" and "[ --help" don't work. However, "/usr/bin/[ --help" does work:
Code Sample
/usr/bin/[ --help
Usage: test EXPRESSION
 or:  [ EXPRESSION ]
 or:  [ OPTION
Exit with the status determined by EXPRESSION.


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





Group: Members
Posts: 3275
Joined: July 2006
Posted: Sep. 10 2007,00:39 QUOTE

In DSL, it looks like [ is a symlink to test.  However, as curaga pointed out, it's also a bash/ash built-in, so removing it could save a couple KB -- unless something else requires it? (and put it in gnu-utils, if it isn't already in there?)

Quote
This is kind of an unusual situation because "man [" and "[ --help" don't work.
I'd guess that the shell would try to parse that... or try to use the built-in function (hence the use of the full path)
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