Changeset 22a2ffd in lab.git for TipAndDoc/.bin


Ignore:
Timestamp:
Oct 4, 2012 6:47:28 PM (12 years ago)
Author:
mitty <mitty@…>
Branches:
master, trunk
Children:
1be8507
Parents:
5eea6d8
Message:
  • #55
  • recursively exec cmpdir script in cmpdir
    • cmpdir dir1 dir2 target -> check dir1/target dir2/target and then cmp dir1/target dir2/target
  • almost finished

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@171 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TipAndDoc/.bin/cmpdir

    r5eea6d8 r22a2ffd  
    44    echo "Usage: $0 directory1 directory2" 
    55    exit 1 
     6fi 
     7if [ $# -eq 3 ]; then 
     8    [ -d "$1/$3" ] && [ -d "$2/$3" ] && 
     9        exit 
     10    [ ! -e "$1/$3" ] && [ ! -e "$2/$3" ] && 
     11        echo "$0: something wrong abount '$3'" >&2 && exit 
     12    [ -e "$1/$3" ] && [ ! -e "$2/$3" ] && 
     13        echo "Only in '$1': '$3'" >&2 && exit 
     14    [ ! -e "$1/$3" ] && [ -e "$2/$3" ] && 
     15        echo "Only in '$2': '$3'" >&2 && exit 
     16    [ -f "$1/$3" ] && [ -d "$2/$3" ] && 
     17        echo "'$1' is a regular file but '$2' is a directory" >&2 && exit 
     18    [ -d "$1/$3" ] && [ -f "$2/$3" ] && 
     19        echo "'$1' is a directory but '$2' is a regular file" >&2 && exit 
     20     
     21    cmp -s "$1/$3" "$2/$3" || echo "$1/$3" "$2/$3" are differ >&2 
     22    exit 
    623fi 
    724if [ -d "$1" -a -d "$2" ]; then 
     
    1532wc=$PWD 
    1633cd "$1" 
    17 find ./ -print0 >> "$tmp" 
     34find -print0 >> "$tmp" 
    1835cd $wc 
    1936 
    2037cd "$2" 
    21 find ./ -print0 >> "$tmp" 
     38find -print0 >> "$tmp" 
    2239cd $wc 
    2340 
    2441sort -z "$tmp" | uniq -z > "$list" 
    2542 
    26 comppath () { 
    27     [ ! -e "$1/$3" ] && [ ! -e "$2/$3" ] && 
    28         (echo "$0: something wrong abount '$3'" >&2; return) 
    29     [ -e "$1/$3" ] && [ ! -e "$2/$3" ] && 
    30         (echo "Only in '$1': '$3'" >&2; return) 
    31     [ ! -e "$1/$3" ] && [ -e "$2/$3" ] && 
    32         (echo "Only in '$2': '$3'" >&2; return) 
    33 } 
    3443 
    35 xargs -a "$list" -0 -n 1 -I entry cmp "$1/entry" "$2/entry" 
     44xargs -a "$list" -0 -n 1 -I entry $0 "$1" "$2" "entry" 
Note: See TracChangeset for help on using the changeset viewer.