Re: A file named "["?

2012-06-06 Thread Michael Schwendt
On Tue, 05 Jun 2012 13:41:59 -0700, jdow wrote:

> On 2012/06/05 13:17, Michael Schwendt wrote:
> > On Tue, 05 Jun 2012 12:35:34 -0700, jdow wrote:
> >
> >> On 2012/06/05 11:55, Michael Schwendt wrote:
> >>> On Tue, 5 Jun 2012 14:40:23 -0400, Alex wrote:
> >>>
>  It's used in shell scripts, such as an "if" statement, such as "if [
>  $? -eq 0 ]". Bash actually runs that command.
> >>>
> >>> Not Bash.
> >>>
> >>> $ type [
> >>> [ is a shell builtin
> >>>
> >>> Also see "man [".
> >>>
> >>
> >> $ type /usr/bin/[
> >> /usr/bin/[ is /usr/bin/[
> >
> > Of course. What are you trying to prove?
> >
> > Bash doesn't run that command. "man test" explains it, too:
> 
> The file is still essential. Some script files may not work if it is
> removed because not all scripts on the system use bash.

Of course, but it was claimed that

  | Bash actually runs that command.

to which I replied. The full quote can be found above. And it has been
pointed out early in this thread that it is a command that belongs into
the coreutils package. So, hopefully everything has been cleared up now.

-- 
Michael Schwendt 
Fedora release 17 (Beefy Miracle) - Linux 3.4.0-1.fc17.x86_64
loadavg: 0.35 0.52 0.40
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread jdow

On 2012/06/05 13:17, Michael Schwendt wrote:

On Tue, 05 Jun 2012 12:35:34 -0700, jdow wrote:


On 2012/06/05 11:55, Michael Schwendt wrote:

On Tue, 5 Jun 2012 14:40:23 -0400, Alex wrote:


It's used in shell scripts, such as an "if" statement, such as "if [
$? -eq 0 ]". Bash actually runs that command.


Not Bash.

$ type [
[ is a shell builtin

Also see "man [".



$ type /usr/bin/[
/usr/bin/[ is /usr/bin/[


Of course. What are you trying to prove?

Bash doesn't run that command. "man test" explains it, too:


The file is still essential. Some script files may not work if it is
removed because not all scripts on the system use bash.

{^_^}
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Jeff Gipson

On Tue, Jun 05, 2012 at 10:17:47PM +0200, Michael Schwendt wrote:

On Tue, 05 Jun 2012 12:35:34 -0700, jdow wrote:


On 2012/06/05 11:55, Michael Schwendt wrote:
> On Tue, 5 Jun 2012 14:40:23 -0400, Alex wrote:
>
>> It's used in shell scripts, such as an "if" statement, such as "if [
>> $? -eq 0 ]". Bash actually runs that command.
>
> Not Bash.
>
> $ type [
> [ is a shell builtin
>
> Also see "man [".
>

$ type /usr/bin/[
/usr/bin/[ is /usr/bin/[


Of course. What are you trying to prove?

Bash doesn't run that command. "man test" explains it, too:

| NOTE: your shell may have its own version of test and/or [, which  usu‐
| ally  supersedes  the  version  described  here.   Please refer to your
| shell's documentation for details about the options it supports.

--
Fedora release 17 (Beefy Miracle) - Linux 3.3.7-1.fc17.x86_64
loadavg: 1.78 1.58 1.44
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


### End of Message from Michael Schwendt ###

I hope this puts the issue to bed:

An unadorned '[' in bash (or borne sh, or zsh, and probably others) 
actually is a built-in command. This speed tests tremendously by 
preventing execing every time a test needs to be performed.


For some ancient shells test (a.k.a. '/usr/bin/[') was an external command. It is 
still provided for backwards compatibility.


In bash you *can* use it, so long as you either call it long-hand:
 $ /usr/bin/\[ -n "$var" ]
But it would be stupid to do so.

Every once in a while, you might encounter a program that execs your 
commands directly, i.e. *not* in a shell. IIRC, Udev RUN= and PROGRAM== 
are examples of these. If you want to test something, then you would 
have to use something like:


  PROGRAM=="bash -c '[ "$a" -eq "$b" ]'

This is clumsy*. Because you have /usr/bin/\[ in the path, you could 
probably get away with:


  PROGRAM=='[ "$a" -eq "$b" ]'

* ok, it's not completely fair to call this clumsy, because when you run 
bash, you also get all your functions, aliases and other built-ins, so 
oftentimes it actually *is* better to use 'bash -c'.


HTH

--
×-×-×-×-×-×-×-×-×-×-×
  Jeffrey A. Gipson
×-×-×-×-×-×-×-×-×-×-×


smime.p7s
Description: S/MIME cryptographic signature
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Michael Schwendt
On Tue, 05 Jun 2012 12:35:34 -0700, jdow wrote:

> On 2012/06/05 11:55, Michael Schwendt wrote:
> > On Tue, 5 Jun 2012 14:40:23 -0400, Alex wrote:
> >
> >> It's used in shell scripts, such as an "if" statement, such as "if [
> >> $? -eq 0 ]". Bash actually runs that command.
> >
> > Not Bash.
> >
> > $ type [
> > [ is a shell builtin
> >
> > Also see "man [".
> >
> 
> $ type /usr/bin/[
> /usr/bin/[ is /usr/bin/[

Of course. What are you trying to prove?

Bash doesn't run that command. "man test" explains it, too:

| NOTE: your shell may have its own version of test and/or [, which  usu‐
| ally  supersedes  the  version  described  here.   Please refer to your
| shell's documentation for details about the options it supports.

-- 
Fedora release 17 (Beefy Miracle) - Linux 3.3.7-1.fc17.x86_64
loadavg: 1.78 1.58 1.44
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread jdow

On 2012/06/05 11:55, Michael Schwendt wrote:

On Tue, 5 Jun 2012 14:40:23 -0400, Alex wrote:


It's used in shell scripts, such as an "if" statement, such as "if [
$? -eq 0 ]". Bash actually runs that command.


Not Bash.

$ type [
[ is a shell builtin

Also see "man [".



$ type /usr/bin/[
/usr/bin/[ is /usr/bin/[

{^_^}
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Antonio Olivares

> > It's used in shell scripts, such as an "if" statement,
> such as "if [
> > $? -eq 0 ]". Bash actually runs that command.
> 
> Not Bash.
> 
> $ type [
> [ is a shell builtin
> 
> Also see "man [".
> 
> -- 

I had seen this and thought I created it with a redirection to it like 
file > [ by mistake
so I nuked it :( but it was not in /usr/bin/ or in /bin(as in Fedora 17) so 
that makes me feel better :)  It was in Documents folder, so all is well.  

Regards,


Antonio 
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Michael Schwendt
On Tue, 5 Jun 2012 14:40:23 -0400, Alex wrote:

> It's used in shell scripts, such as an "if" statement, such as "if [
> $? -eq 0 ]". Bash actually runs that command.

Not Bash.

$ type [
[ is a shell builtin

Also see "man [".

-- 
Fedora release 17 (Beefy Miracle) - Linux 3.3.7-1.fc17.x86_64
loadavg: 0.93 0.80 1.02
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Alex
Hi,

>>>        On one of my PCs, /bin contains an executable file whose name is
>>> the left square bracket, and nothing else.
>>>
>>>        Opening it with gedit gets something that's part text (generally
>>> if not all commented out) and part stuff I can't read.
>>>
>>>        Is there a test, usable by one who knows no code, whether it's
>>> malware??
>>>
>>>        What should I do?
>>
>>
>>   you should leave it there -- it's an actual command.
>
> Specifically it belongs to "coreutils-8.4-16.el6.x86_64".

It's used in shell scripts, such as an "if" statement, such as "if [
$? -eq 0 ]". Bash actually runs that command.

If you're really concerned about security, you could check out
rkhunter or search for "detecting root kits".

Best,
Alex
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Chris Tyler
On Tue, 2012-06-05 at 18:16 +, Beartooth wrote:
>   On one of my PCs, /bin contains an executable file whose name is 
> the left square bracket, and nothing else. 
> 
>   Opening it with gedit gets something that's part text (generally 
> if not all commented out) and part stuff I can't read.
> 
>   Is there a test, usable by one who knows no code, whether it's 
> malware??
> 
>   What should I do? 

You can find out if a particular file is part of a package that you've
installed like this:

$ rpm -qf /usr/bin/[
coreutils-8.12-7.fc16.x86_64

To check whether any files in that package have changed, substitute
"-V" (verify) for "-q" in the line above.

In the case of the executable named "[", it's the test command in
sheep's clothing, part of the coreutils package on most Fedora systems.
See "man test" for details.

-Chris

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Rick Stevens

On 06/05/2012 11:19 AM, Robert P. J. Day wrote:

On Tue, 5 Jun 2012, Beartooth wrote:



On one of my PCs, /bin contains an executable file whose name is
the left square bracket, and nothing else.

Opening it with gedit gets something that's part text (generally
if not all commented out) and part stuff I can't read.

Is there a test, usable by one who knows no code, whether it's
malware??

What should I do?


   you should leave it there -- it's an actual command.


It's actually in /usr/bin. It's legit and a version of the "test"
command. Buried in it (via the "strings" command), you'll find:

Usage: test EXPRESSION
  or:  test
  or:  [ EXPRESSION ]
  or:  [ ]
  or:  [ OPTION

--
- Rick Stevens, Systems Engineer, AllDigitalri...@alldigital.com -
- AIM/Skype: therps2ICQ: 22643734Yahoo: origrps2 -
--
-I don't suffer from insanity...I enjoy every minute of it!  -
--
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread jdow

On 2012/06/05 11:19, Robert P. J. Day wrote:

On Tue, 5 Jun 2012, Beartooth wrote:



On one of my PCs, /bin contains an executable file whose name is
the left square bracket, and nothing else.

Opening it with gedit gets something that's part text (generally
if not all commented out) and part stuff I can't read.

Is there a test, usable by one who knows no code, whether it's
malware??

What should I do?


   you should leave it there -- it's an actual command.

rday


Specifically it belongs to "coreutils-8.4-16.el6.x86_64".

{^_^}
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: A file named "["?

2012-06-05 Thread Robert P. J. Day
On Tue, 5 Jun 2012, Beartooth wrote:

>
>   On one of my PCs, /bin contains an executable file whose name is
> the left square bracket, and nothing else.
>
>   Opening it with gedit gets something that's part text (generally
> if not all commented out) and part stuff I can't read.
>
>   Is there a test, usable by one who knows no code, whether it's
> malware??
>
>   What should I do?

  you should leave it there -- it's an actual command.

rday

-- 


Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca

Twitter:   http://twitter.com/rpjday
LinkedIn:   http://ca.linkedin.com/in/rpjday

-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


A file named "["?

2012-06-05 Thread Beartooth

On one of my PCs, /bin contains an executable file whose name is 
the left square bracket, and nothing else. 

Opening it with gedit gets something that's part text (generally 
if not all commented out) and part stuff I can't read.

Is there a test, usable by one who knows no code, whether it's 
malware??

What should I do? 

-- 
Beartooth Staffwright, Neo-Redneck Not Quite Clueless Power User
I have precious (very precious!) little idea where up is.


-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org