File: install_ln.sh

package info (click to toggle)
faucc 20090220-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,356 kB
  • ctags: 2,846
  • sloc: ansic: 38,010; yacc: 1,595; xml: 519; lex: 378; makefile: 120; sh: 101
file content (39 lines) | stat: -rwxr-xr-x 750 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

# $Id: install_ln.sh,v 1.2 2009-01-27 16:09:12 potyra Exp $
#
# mimic install but use soft links instead
#
# Copyright (C) 2009 FAUcc Team.
# This program is free software. You can redistribute it and/or modify it
# under the terms of the GNU General Public License, either version 2 of
# the License, or (at your option) any later version. See COPYING.
#

if [ $1 = '-c' ]; then
	# -c -> ignored
	shift
fi

if [ $1 = '-m' ]; then
	# mode -> ignore
	shift
	shift
fi

SRC=$1
shift
TRG=$1

if [ ! -e "$SRC" ]; then
	echo "$SRC no such file or directory."
	exit 1
fi

if [ -e "$TRG" -a \( ! \( -h "$TRG" \) \) ]; then
	echo "$TRG exists and is not a symbolic link."
fi

TRGDIR=$(dirname "$TRG")
mkdir -p "$TRGDIR"
ln -sf "$(pwd)/$SRC" "$TRG"