using library functions in shell script

hey guys,

i made up a library file called common.lib so as to reuse the same code without typing it again. here is the code. its pretty basic .

## This is the second function

compare()
{

file1 = $1

file2 = $2

cmp $file1 $file2

if [ $file1 -eq $file2 ]
then
        echo "comparison is possible"
else
        echo "compariosn is not possible"
fi
}

i have another shell script that uses the function 'compare' from the library file . here is the code.

#!/usr/bin/bash

. ./common.lib
compare $file1 $file2

i know i am going wrong somewhere because when i try to execute the shell script, the cursor just waits at the console without spitting out any output. after a while i have to terminate the process using ctrl+c . please tell me where i am going wrong.

thanks
Arsenalboy.

try this:

compare()
{

file1=$1

file2=$2

cmp $file1 $file2 2>/dev/null

if [ $? -eq 1 ]
then
        echo "comparison is possible"
else
        echo "compariosn is not possible"
fi
}

and then run your script:

./yourscript file1 file2