User:Krikko: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Krikko (talk | contribs)
No edit summary
Krikko (talk | contribs)
No edit summary
Line 8: Line 8:
if [ $oigused = $2 ];
if [ $oigused = $2 ];
then
then
echo 0
exit 0
fi
fi
#õigustest substring ja nende võrdlemine
#õigustest substring ja nende võrdlemine
if [ ! $(expr substr $2 1 1) = $(expr substr $oigused 1 1) ]  
if [ ! $(expr substr $2 1 1) = $(expr substr $oigused 1 1) ]  
then
then
echo 2
exit 2
fi
fi
if [ ! $(expr substr $2 2 1) = $(expr substr $oigused 2 1) ]  
if [ ! $(expr substr $2 2 1) = $(expr substr $oigused 2 1) ]  
then
then
echo 3
exit 3
fi
fi
if [ ! $(expr substr $2 3 1) = $(expr substr $oigused 3 1) ]  
if [ ! $(expr substr $2 3 1) = $(expr substr $oigused 3 1) ]  
then
then
echo 4
exit 4
fi
fi
#faili ei leitud
#faili ei leitud
else
else
echo 1
exit 1
fi
fi
</source>
</source>

Revision as of 13:45, 12 May 2011

#faili olemasolu
if [ -e "$1" ];
then
	#faili õigused numbrilisel kujul
	oigused=$(stat -c %a $1)
	#faili ja sisendi õigused samad
	if [ $oigused = $2 ];
	then
	exit 0
	fi
	#õigustest substring ja nende võrdlemine
	if [ ! $(expr substr $2 1 1) = $(expr substr $oigused 1 1) ] 
	then	
	exit 2
	fi
	if [ ! $(expr substr $2 2 1) = $(expr substr $oigused 2 1) ] 
	then	
	exit 3
	fi
	if [ ! $(expr substr $2 3 1) = $(expr substr $oigused 3 1) ] 
	then	
	exit 4
	fi
#faili ei leitud
else
exit 1
fi