#!/bin/csh # CVS: $Id$ # Name: pc_localize # Author: wd (Wolfgang.Dobler@kis.uni-freiburg.de) # Date: 17-Jul-2002 # Description: # Materialize a link to one or several files or directories (the latter # will not work under some unices (but under Linux). if ( ($#argv < 1) || ("$1" == "-h") || ("$1" == "--help") ) goto usage set hard = 0 if ( ("$1" == "-H") || ("$1" == "--hard") ) then set hard = 1 shift endif set tmpfile = tmp.$$ if (`uname -s` =~ Linux) then set deref = "-L" # flag to cp for dereferencing links else set deref = "" # OK at least under OSF1 endif foreach f ( $* ) if (-l $f) then if ($hard) then ln -f `readlink $f` $f else if (-d $f) then # link to directory cp -rp $deref $f $tmpfile && rm $f && mv $tmpfile $f else # link to file cp -p $f $tmpfile && rm $f && mv $tmpfile $f endif endif else echo "Not a link: $f" endif end exit usage: set cmd_name = "$0" # OSF1 is idiosyncratic set cmd_name = ${cmd_name:t} echo "Usage:" echo " $cmd_name [-H] [ ..]" echo "" echo "Replace a link to a file by a copy. Will also work on directories," echo "but only under some unix dialects (Linux and OSF1 in particular)." echo "With '-H', replace soft link by a hard link" # End of file local