1#!/bin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License, Version 1.0 only 7# (the "License"). You may not use this file except in compliance 8# with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or http://www.opensolaris.org/os/licensing. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23# 24# Copyright (c) 1993-1998 by Sun Microsystems, Inc. 25# All rights reserved. 26# 27#pragma ident "%Z%%M% %I% %E% SMI" 28# 29# This script is to be used to move SCCS files and SCCS 30# directories within a CodeManager workspace. You 31# specifiy the 'clear file' or the directory to sccsmv, 32# it will move both the 'clear file' and the coresponding 33# s-dot, and if present, p-dot files. 34# 35 36USAGE="usage: sccsmv filename1 [filename2 ...] target" 37 38 39# 40# function to return that last arguement passed to it. 41# I use this in place of array indexing - which shell 42# does not do well. 43# 44getlast() 45{ 46 for arg in $* 47 do 48 : 49 done 50 echo "$arg" 51} # getlast() 52 53move_file() 54{ 55 f1=`basename $1` 56 d1=`dirname $1` 57 s1="$d1/SCCS/s.$f1" 58 p1="$d1/SCCS/p.$f1" 59 f2=`basename $2` 60 d2=`dirname $2` 61 s2="$d2/SCCS/s.$f2" 62 p2="$d2/SCCS/p.$f2" 63 64 if [ ! -d $d2/SCCS ]; then 65 mkdir $d2/SCCS 66 fi 67 mv $s1 $s2 68 mv $1 $2 69 if [ -f $p1 ]; then 70 mv $p1 $p2 71 fi 72} #move_file 73 74if [ $# -lt 2 ]; then 75 echo "Insufficient arguments ($#)" 76 echo $USAGE 77 exit 1 78fi 79 80lastarg=`getlast $*` 81 82if [ "(" $# -gt 2 ")" -a "(" ! -d $lastarg ")" ]; then 83 echo "sccsmv: Target must be a directory" 84 echo $USAGE 85 exit 1 86fi 87 88while [ $# -gt 1 ] 89do 90 if [ ! -r $1 ]; then 91 echo "sccsmv: cannot access $1" 92 shift 93 continue 94 fi 95 if [ -d $lastarg ]; then 96 dest=$lastarg/`basename $1` 97 else 98 dest=$lastarg 99 fi 100 if [ -d $1 ]; then 101 mv $1 $dest 102 else 103 move_file $1 $dest 104 fi 105 shift 106done 107