File: delink

package info (click to toggle)
smartlist 3.15-28
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,308 kB
  • sloc: ansic: 9,238; sh: 4,901; makefile: 118
file content (28 lines) | stat: -rwxr-xr-x 818 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /bin/sh
: &&O='cd .' || exec /bin/sh "$0" $argv:q # we're in a csh, feed myself to sh
$O || exec /bin/sh "$0" "$@"		  # we're in a buggy zsh
#########################################################################
#	delink		Gracefully disconnects a hardlinked file	#
#									#
#	Created by S.R. van den Berg, The Netherlands			#
#########################################################################
#$Id: delink,v 1.7 1995/03/20 14:49:56 berg Exp $

echo=echo		# /bin/echo
test=test		# /bin/test
rm=rm			# /bin/rm
mv=mv			# /bin/mv
cp=cp			# /bin/cp
dirname=dirname		# /bin/dirname

$test 0 = $# && $echo "Usage: delink filename ..." 1>&2 && exit 64

TMPF=delink.$$

trap "$rm -f \$TMPF; exit 1" 1 2 3 13 15

for a in "$@"
do
  TMPF=`dirname "$a"`/delink.$$
  $cp -p "$a" "$TMPF" && $mv -f "$TMPF" "$a"
done