Re: SOLVED(?): [expert] test command

2002-12-22 Thread ath1410
Solved! I should have read man bash pages!

Options are one of the Arguments.

test arg1 arg2 arg3 ..

So,

$test -nCR or $test -zCR is just like $test abcCR.
-n, -z, or abc is handled as arg1 and as 'a string'. Then
test deos not think that -z or -n is an option statement.
The arg1 (-z or -a or -*) can be considered option only if
test has arg2. Without arg2, -z or -n or -* should be handled
just like abc. 

1 argument
The expression is true if and only if the argument is not null.

Then $test -*;echo$? returns 0(true) and $test "";echo$? returns
1(false).

And in case of no argment which is just $testCR, man bash
says 
0 argment - The expression is false.

am i right??


+-+ * Get your own Jmail account.|URL= http://www.jmail.co.jp
|--jmail--| * Get your own home page.|URL= http://www.servance.jp
+-+ * Get your own domain.|URL= http://domaintorou.com/


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] test command

2002-12-20 Thread ath1410
Tks for reply.

I understand the way $test -z "" returns 0 and $test -n "" returns 1.

What's puzzling me here is this.

$test -z (there is no space after -z, no argment) returns 0 which means 'test command 
thinks no argment equals to the
empty string'.

However, $test -n (no space after, no argment) return 0 which
means 'test command in this case thinks no argment equals to
NO-empty string'.

When no argment is given, why test command thinks differenly
depending on the options -z and -n. 
 
Can you help??


On Thu, Dec 19, 2002 at 12:44:30PM +0900, ath1410 wrote:
 $test -z ""
this tests whether the string is empty. in this example it
is, therefor exit code 0.

 
 But it returns different value after followings.
 
 $test -n ""-- echo$? returns 1
 $test -n   --  "   " 0

this tests whether the string is NOT empty. the first one
is empty, so exit code is 1. the second one isn't empty.
i guess that you think that spaces count as empty strings,
but a space is a character as everyone (ascii 039), 
therefor your string isnt empty and exit code is 0.

okey?

have phun;)
miLosh

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+-+ * Get your own Jmail account.|URL= http://www.jmail.co.jp
|--jmail--| * Get your own home page.|URL= http://www.servance.jp
+-+ * Get your own domain.|URL= http://domaintorou.com/
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] test command

2002-12-20 Thread ath1410
Tks Mr.miLosh  Mr.Dean,

This problem is getting clear now. However, let me please
ask one more question that still remains in me.

Mr.miLosh advised;

first of all, in the '-z' example u r giving a string, 
which means 'test' has something to test for. depending on
the argument, it returns its exit code.

No, in the '-z' example, I am NOT giveing a string.

   $test -zCR --  NOT $test -zspaceCR


Mr.Dean advised;

So `test' is saying to itself "I have no arg2 to test against.
Formally, 

   arg2 does not exist == arg2 is not a string.

Hence you get an automatic "false".

Yes, I understand why $test -nCR returns 0. As you mentioned,
no argment is different from no string.

But this assumptions also apply '-z' option, isn't it? If so,
$test -zCR should return 1 not 0, because `test' should say
to itself (as in -z case) that I have no arg to test against,
then it should return authentic `false'. 

I read comments from Mr.miLosh  Mr.Dean many time and tried
test command in various patters many times. (I should have
studied English harder!!) And finally I came up with a
conclusion as Mr.which quotes;

'it is common in programms return a 0 value if a needed
argument is missing.' So test returns 0 if no arg is given
after -* option. Thus both $test -zCR and $test -nCR returns 0.

Now I forced myself to be clear on this!! But why $testCR
(no option, no args) returns 1 now, not 0!!

I agagin have to force myself into thinking that it's a rule.




+-+ * Get your own Jmail account.|URL= http://www.jmail.co.jp
|--jmail--| * Get your own home page.|URL= http://www.servance.jp
+-+ * Get your own domain.|URL= http://domaintorou.com/


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] test command

2002-12-19 Thread ath1410
Tks for reply.

I understand the way $test -z "" returns 0 and $test -n "" returns 1.

What's puzzling me here is this.

$test -z (there is no space after -z, no argment) returns 0 which means 'test command 
thinks no argment equals to the
empty string'.

However, $test -n (no space after, no argment) return 0 which
means 'test command in this case thinks no argment equals to
NO-empty string'.

When no argment is given, why test command thinks differenly
depending on the options -z and -n. 
 
Can you help??


On Thu, Dec 19, 2002 at 12:44:30PM +0900, ath1410 wrote:
 $test -z ""
this tests whether the string is empty. in this example it
is, therefor exit code 0.

 
 But it returns different value after followings.
 
 $test -n ""-- echo$? returns 1
 $test -n   --  "   " 0

this tests whether the string is NOT empty. the first one
is empty, so exit code is 1. the second one isn't empty.
i guess that you think that spaces count as empty strings,
but a space is a character as everyone (ascii 039), 
therefor your string isnt empty and exit code is 0.

okey?

have phun;)
miLosh



""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+-+ * Get your own Jmail account.|URL= http://www.jmail.co.jp
|--jmail--| * Get your own home page.|URL= http://www.servance.jp
+-+ * Get your own domain.|URL= http://domaintorou.com/
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



[expert] test command

2002-12-18 Thread ath1410
$echo $? returns 0 after these test commands.

$test -z ""
$test -z

But it returns different value after followings.

$test -n ""-- echo$? returns 1
$test -n   --  "   " 0

Can someone explain why it goes as above? Especially
I don't figure out why $test -n returns 0.

+-+ * Get your own Jmail account.|URL= http://www.jmail.co.jp
|--jmail--| * Get your own home page.|URL= http://www.servance.jp
+-+ * Get your own domain.|URL= http://domaintorou.com/


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Riddle

2002-11-22 Thread ath1410
tks, Mr Larry.

I checked the sites you refered, but did not still quite figure
out (partly because of my poor English?) the way bash works the
way it does. To make things simple, just take up one case here.

$PS1=u   -4  returns \u

the 1st \ escapes the 2nd \, and the 3rd one to the 4th one
likewise.

So  $PS1=u is something like $PS1='\\u' ( which actually
returns \u, not user name.

It seems to me that when bash handles $PS1='\\u', 1st \ escapes
the 2nd one and  $PS1='\\u' seems equal to $PS1='\u' which
returns user name.

How shell recognize $PS1='\\u' and how shell return \u, not a
user name?

This problem is pestering me for 3 whole days. Please help!







Larry Sword wrote:

ath1410 wrote:

  

Can someone help! I have been trying to explain the way bash
works as follows.

$PS1=\\u -2  returns user
$PS1=\\\u-3  returns user
$PS1=u   -4  returns \u
$PS1=\u  -5  returns \u
$PS1=\\u -6  returns \user
$PS1=\\\u-7  returns \user
$PS1=u   -8  returns \u
$PS1=\u  -9  returns \u
$PS1=\\u-10  returns \user
$PS1=\\\u   -11  returns \user
$PS1=u  -12  returns \\u

I can understand somewhere around;

$PS1=\\\u-3  returns user

But more than that, I can't figure out why bash respond
as it does. What the logic behind it?

 



Review the two HOWTO's:

1. BASH Programming-Introduction HOW-TO

and

2. From Power Up to Bash Prompt

Should be: Bash Prompt HOWTO @ 
http://www.linuxselfhelp.com/HOWTO/Bash-Prompt-HOWTO/


This probable is answered as a string comparsion operators.

Larry


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

+-+ * Get your own Jmail account.|URL= http://www.jmail.co.jp
|--jmail--| * Get your own home page.|URL= http://www.servance.jp
+-+ * Get your own domain.|URL= http://domaintorou.com/


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



[expert] Riddle

2002-11-21 Thread ath1410
Can someone help! I have been trying to explain the way bash
works as follows.

$PS1=\\u -2  returns user
$PS1=\\\u-3  returns user
$PS1=u   -4  returns \u
$PS1=\u  -5  returns \u
$PS1=\\u -6  returns \user
$PS1=\\\u-7  returns \user
$PS1=u   -8  returns \u
$PS1=\u  -9  returns \u
$PS1=\\u-10  returns \user
$PS1=\\\u   -11  returns \user
$PS1=u  -12  returns \\u

I can understand somewhere around;

$PS1=\\\u-3  returns user

But more than that, I can't figure out why bash respond
as it does. What the logic behind it?

+-+ * Get your own Jmail account.|URL= http://www.jmail.co.jp
|--jmail--| * Get your own home page.|URL= http://www.servance.jp
+-+ * Get your own domain.|URL= http://domaintorou.com/


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com