cmv revision 139969
1235368Sgnn#!/bin/sh
2235368Sgnn
3235368Sgnn#-
4235368Sgnn# Copyright (c) 1991, 1993
5235368Sgnn#	The Regents of the University of California.  All rights reserved.
6235368Sgnn#
7235368Sgnn# This code is derived from software contributed to Berkeley by
8235368Sgnn# Kenneth Almquist.
9235368Sgnn#
10235368Sgnn# Redistribution and use in source and binary forms, with or without
11235368Sgnn# modification, are permitted provided that the following conditions
12235368Sgnn# are met:
13235368Sgnn# 1. Redistributions of source code must retain the above copyright
14235368Sgnn#    notice, this list of conditions and the following disclaimer.
15235368Sgnn# 2. Redistributions in binary form must reproduce the above copyright
16235368Sgnn#    notice, this list of conditions and the following disclaimer in the
17235368Sgnn#    documentation and/or other materials provided with the distribution.
18235368Sgnn# 4. Neither the name of the University nor the names of its contributors
19235368Sgnn#    may be used to endorse or promote products derived from this software
20235368Sgnn#    without specific prior written permission.
21235368Sgnn#
22235368Sgnn# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23235368Sgnn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24235368Sgnn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25235368Sgnn# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26235368Sgnn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27235368Sgnn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28235368Sgnn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29235368Sgnn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30235368Sgnn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31235368Sgnn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32235368Sgnn# SUCH DAMAGE.
33235368Sgnn#
34235368Sgnn#	@(#)cmv	8.2 (Berkeley) 5/4/95
35235368Sgnn# $FreeBSD: head/bin/sh/funcs/cmv 139969 2005-01-10 08:39:26Z imp $
36235368Sgnn
37235368Sgnn# Conditional move--don't replace an existing file.
38235368Sgnn
39235368Sgnncmv() {
40235368Sgnn	if test $# != 2
41235368Sgnn	then	echo "cmv: arg count"
42235368Sgnn		return 2
43235368Sgnn	fi
44235368Sgnn	if test -f "$2" -o -w "$2"
45235368Sgnn	then	echo "$2 exists"
46235368Sgnn		return 2
47235368Sgnn	fi
48235368Sgnn	/bin/mv "$1" "$2"
49235368Sgnn}
50235368Sgnn