home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / file / logiso.000 / logiso / Utils / RCS / replace_link,v < prev    next >
Encoding:
Text File  |  1995-03-24  |  1.8 KB  |  99 lines

  1. head    1.3;
  2. access;
  3. symbols
  4.     VER_0_3:1.3
  5.     VER_0_2:1.2;
  6. locks; strict;
  7. comment    @# @;
  8.  
  9.  
  10. 1.3
  11. date    95.03.24.11.43.35;    author coulter;    state Exp;
  12. branches;
  13. next    1.2;
  14.  
  15. 1.2
  16. date    95.02.19.16.06.41;    author coulter;    state Exp;
  17. branches;
  18. next    1.1;
  19.  
  20. 1.1
  21. date    95.02.18.08.36.38;    author coulter;    state Exp;
  22. branches;
  23. next    ;
  24.  
  25.  
  26. desc
  27. @replace a link with a different link
  28. @
  29.  
  30.  
  31. 1.3
  32. log
  33. @Checkin version for 0.3 distribution.
  34. @
  35. text
  36. @#! /bin/ksh
  37. USAGE='USAGE: replace_link  FILE_PATH DEST_PATH
  38.    FILE_PATH should be a link whose ultimate desitnation is DEST_PATH.
  39.    Replace FILE_PATH with a link to DEST_PATH.
  40. '
  41. # (C) Copyright 1995 by Michael Coulter.  All rights reserved.
  42.  
  43. # Process parameters
  44.    if [ $# -ne 2 ]
  45.    then
  46.       echo "$USAGE" >&2
  47.       echo "Expected 2 arguments, got $#" >&2
  48.       exit 1
  49.    fi
  50.    FILE_PATH="$1"; shift
  51.    DEST_PATH="$1"; shift
  52.    ##echo "replace_link: At 1, DEST_PATH is $DEST_PATH"
  53.    if [ ! -L "$FILE_PATH" ]
  54.    then
  55.       echo "$USAGE" >&2
  56.       echo "FILE_PATH, $FILE_PATH , is not a link." >&2
  57.       exit 1
  58.    fi
  59.    ##echo "replace_link: At 1, DEST_PATH is $DEST_PATH"
  60.    ##echo "replace_link: At 1, FILE_PATH is $FILE_PATH"
  61.    ##echo "replace_link: At 2, DEST_PATH is $DEST_PATH"
  62.    # If DEST_PATH starts with the directory of $FILE, then use a 
  63.    # relative link
  64.    FRONT="$(dirname "$FILE_PATH")/"
  65.    eval "DEST_PATH=\"${DEST_PATH#${FRONT}}\""
  66.    ##echo "replace_link: At 3, DEST_PATH is $DEST_PATH"
  67.    echo "replace_link: Replace $FILE_PATH with $DEST_PATH"
  68.    rm "$FILE_PATH"
  69.    ln -s "$DEST_PATH" "$FILE_PATH"
  70.    exit 0
  71. @
  72.  
  73.  
  74. 1.2
  75. log
  76. @Checkpoint version 0.1
  77. @
  78. text
  79. @d6 1
  80. @
  81.  
  82.  
  83. 1.1
  84. log
  85. @Checkpoint version before fixing /usr/bin install
  86. @
  87. text
  88. @d16 1
  89. d23 3
  90. a25 6
  91.    if [ -L "$DEST_PATH" -o ! -e "$DEST_PATH" ]
  92.    then
  93.       echo "$USAGE" >&2
  94.       echo "DEST_PATH, $DEST_PATH , does not exist or is a link." >&2
  95.       exit 1
  96.    fi
  97. d30 1
  98. @
  99.