echo "Usage: $0 directory1 directory2"
exit 1
fi
+if [ $# -eq 3 ]; then
+ [ -d "$1/$3" ] && [ -d "$2/$3" ] &&
+ exit
+ [ ! -e "$1/$3" ] && [ ! -e "$2/$3" ] &&
+ echo "$0: something wrong abount '$3'" >&2 && exit
+ [ -e "$1/$3" ] && [ ! -e "$2/$3" ] &&
+ echo "Only in '$1': '$3'" >&2 && exit
+ [ ! -e "$1/$3" ] && [ -e "$2/$3" ] &&
+ echo "Only in '$2': '$3'" >&2 && exit
+ [ -f "$1/$3" ] && [ -d "$2/$3" ] &&
+ echo "'$1' is a regular file but '$2' is a directory" >&2 && exit
+ [ -d "$1/$3" ] && [ -f "$2/$3" ] &&
+ echo "'$1' is a directory but '$2' is a regular file" >&2 && exit
+
+ cmp -s "$1/$3" "$2/$3" || echo "$1/$3" "$2/$3" are differ >&2
+ exit
+fi
if [ -d "$1" -a -d "$2" ]; then
echo "$0: start comparing '$1' and '$2'" >&2
fi
wc=$PWD
cd "$1"
-find ./ -print0 >> "$tmp"
+find -print0 >> "$tmp"
cd $wc
cd "$2"
-find ./ -print0 >> "$tmp"
+find -print0 >> "$tmp"
cd $wc
sort -z "$tmp" | uniq -z > "$list"
-comppath () {
- [ ! -e "$1/$3" ] && [ ! -e "$2/$3" ] &&
- (echo "$0: something wrong abount '$3'" >&2; return)
- [ -e "$1/$3" ] && [ ! -e "$2/$3" ] &&
- (echo "Only in '$1': '$3'" >&2; return)
- [ ! -e "$1/$3" ] && [ -e "$2/$3" ] &&
- (echo "Only in '$2': '$3'" >&2; return)
-}
-xargs -a "$list" -0 -n 1 -I entry cmp "$1/entry" "$2/entry"
+xargs -a "$list" -0 -n 1 -I entry $0 "$1" "$2" "entry"