154310Smarcel#! /bin/sh
254310Smarcel#
354310Smarcel# Copyright (c) 1999 Marcel Moolenaar
454310Smarcel# All rights reserved.
554310Smarcel#
654310Smarcel# Redistribution and use in source and binary forms, with or without
754310Smarcel# modification, are permitted provided that the following conditions
854310Smarcel# are met:
954310Smarcel# 1. Redistributions of source code must retain the above copyright
1054310Smarcel#    notice, this list of conditions and the following disclaimer 
1154310Smarcel#    in this position and unchanged.
1254310Smarcel# 2. Redistributions in binary form must reproduce the above copyright
1354310Smarcel#    notice, this list of conditions and the following disclaimer in the
1454310Smarcel#    documentation and/or other materials provided with the distribution.
1554310Smarcel# 3. The name of the author may not be used to endorse or promote products
1697748Sschweikh#    derived from this software without specific prior written permission
1754310Smarcel#
1854310Smarcel# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1954310Smarcel# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2054310Smarcel# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2154310Smarcel# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2254310Smarcel# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2354310Smarcel# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2454310Smarcel# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2554310Smarcel# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2654310Smarcel# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2754310Smarcel# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2854310Smarcel#
2954310Smarcel# $FreeBSD$
3054310Smarcel
3154310Smarcel# parse install's options and ignore them completely.
32218940Suqsdirmode=""
33245751Sbrookslinkmode=""
34125514Sruwhile [ $# -gt 0 ]; do
3554310Smarcel    case $1 in
36218940Suqs    -d) dirmode="YES"; shift;;
37245751Sbrooks    -[bCcpSsv]) shift;;
38245751Sbrooks    -[BDfghMmNoTU]) shift; shift;;
39245751Sbrooks    -[BDfghMmNoTU]*) shift;;
40245751Sbrooks    -l)
41245751Sbrooks	shift
42245751Sbrooks	case $1 in
43245751Sbrooks	*[sm]*) linkmode="symbolic";;	# XXX: 'm' should prefer hard
44245751Sbrooks	*h*) linkmode="hard";;
45245751Sbrooks	*) echo "invalid link mode"; exit 1;;
46245751Sbrooks	esac
47245751Sbrooks	shift
48245751Sbrooks	;;
4954310Smarcel    *) break;
5054310Smarcel    esac
5154310Smarceldone
5254310Smarcel
53218940Suqsif [ "$#" -eq 0 ]; then
54218940Suqs	echo "$0: no files/dirs specified" >&2
55218940Suqs	exit 1
56218940Suqsfi
57218940Suqs
58218940Suqsif [ -z "$dirmode" ] && [ "$#" -lt 2 ]; then
59218940Suqs	echo "$0: no target specified" >&2
60218940Suqs	exit 1
61218940Suqsfi
62218940Suqs
6354389Smarcel# the remaining arguments are assumed to be files/dirs only.
64245751Sbrooksif [ -n "${linkmode}" ]; then
65245893Sbrooks	if [ "${linkmode}" = "symbolic" ]; then
66245751Sbrooks		ln -fsh "$@"
67245751Sbrooks	else
68245751Sbrooks		ln -f "$@"
69245751Sbrooks	fi
70245751Sbrookselif [ -z "$dirmode" ]; then
71218940Suqs	exec install -p "$@"
72218940Suqselse
73218940Suqs	exec install -d "$@"
74218940Suqsfi
75