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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#!/bin/sh
#
# Copyright (C) 2009 FAUmachine Team <info@faumachine.org>.
# 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.
#
#
# mimic install but use soft links instead
#
if [ $1 = '-c' ]; then
# -c -> ignored
shift
fi
if [ $1 = '-m' ]; then
# mode -> ignore
shift
shift
fi
eval TRG="\${$#}"
# more than two arguments? -> target is directory.
if [ $# -gt 2 ]; then
if [ ! -d "$TRG" ]; then
echo "$TRG is not a directory."
exit 1
fi
fi
TARGET_IS_DIR=0
if [ -d "$TRG" ]; then
TARGET_IS_DIR=1
fi
while [ $# -gt 1 ]; do
SRC=$1
shift
if [ ! -e "$(pwd)/$SRC" ]; then
echo "$SRC no such file or directory."
exit 1
fi
if [ $TARGET_IS_DIR -eq 1 ]; then
DST="$TRG/$(basename $SRC)"
else
DST="$TRG"
fi
if [ -e "$DST" -a \( ! \( -h "$DST" \) \) ]; then
echo "$DST exists and is not a symbolic link. Skipping."
continue
fi
echo ln -sf "$(pwd)/$SRC" "$TRG"
ln -sf "$(pwd)/$SRC" "$TRG"
done
|