Hi!

I've got some questions to the use of conditional expressions. I took a look 
at the bash manual page, but nevertheless would like some more explanation.

First, there is the "/etc/profile.d/readline.sh" file:

When is the following expression true?

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
        INPUTRC=/etc/inputrc
fi

bash manual says:
----------------------------

-z string 
 True if the length of string is zero.

-a file 
 True if file exists.

-f file 
 True if file exists and is a regular file.


SHELL BUILTIN COMMANDS

test and [ evaluate conditional expressions using a set of rules based on the 
number of arguments. 

0 arguments
 The expression is false. 
1 argument
 The expression is true if and only if the argument is not null. 
2 arguments
 If the first argument is !, the expression is true if and only if the second 
argument is null. If the first argument is one of the unary conditional 
operators listed above under CONDITIONALEXPRESSIONS,  the expression is true 
if the unary test is true. If the first argument is not a valid unary 
conditional operator, the expression is false. 
3 arguments
 If the second argument is one of the binary conditional operators listed 
above under CONDITIONALEXPRESSIONS,  the result of the expression is the 
result of the binary test using the first and third arguments as operands. If 
the first argument is !, the value is the negation of the two-argument test 
using the second and third arguments. If the first argument is exactly ( and 
the third argument is exactly ), the result is the one-argument test of the 
second argument. Otherwise, the expression is false. The -a and -o operators 
are considered binary operators in this case. 
4 arguments
 If the first argument is !, the result is the negation of the three-argument 
expression composed of the remaining arguments. Otherwise, the expression is 
parsed and evaluated according to precedence using the rules listed above. 
5 or more arguments
 The expression is parsed and evaluated according to precedence using the 
rules listed above. 


Next there is the "/etc/profile.d/umask.sh" file:

When is the following expression true?

if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
  umask 002
else
  umask 022
fi


id manual says:
-----------------------

-g, --group
 print only the effective group ID

-n, --name
 print a name instead of a number, for -ugG

-u, --user
 print only the effective user ID


bash manual says:
----------------------------

PARAMETERS

Shell Variables

EUID 
 Expands to the effective user ID of the current user, initialized at shell 
startup. This variable is readonly.



What I have some problems to understand is, how the parts of each conditional 
expressions are connected in order to get one result.

Kind regards,
Leonhard.
-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to