summaryrefslogtreecommitdiffstats
path: root/contrib/top/install-sh
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-03-10 11:46:41 +0000
committerrwatson <rwatson@FreeBSD.org>2009-03-10 11:46:41 +0000
commit40428b7066791309c08329cc6cf68ac5491dd8a3 (patch)
tree4369a4648e940221c380eab8a41b694691af6ffc /contrib/top/install-sh
parentb2737cb9ed157467f6f1fb032e215d056013388e (diff)
downloadFreeBSD-src-40428b7066791309c08329cc6cf68ac5491dd8a3.zip
FreeBSD-src-40428b7066791309c08329cc6cf68ac5491dd8a3.tar.gz
Merge r183430 from vendor/top/dist to head/contrib/top, although with
record-only mergeinfo because an automated merge is confused by the flattening that took place: Move install to install-sh to prevent name-clashes. MFC after: 3 days
Diffstat (limited to 'contrib/top/install-sh')
-rwxr-xr-xcontrib/top/install-sh69
1 files changed, 69 insertions, 0 deletions
diff --git a/contrib/top/install-sh b/contrib/top/install-sh
new file mode 100755
index 0000000..d8b6283
--- /dev/null
+++ b/contrib/top/install-sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# this shell script is amazingly similar to the old and lamented
+# BSD "install" command. It recognized the following options:
+#
+# -o target file owner
+# -m target file mode
+# -g target file group owner
+#
+#
+# scan the options
+#
+while [ $# -gt 0 ]; do
+ case $1 in
+ -o)
+ owner=$2
+ shift ; shift
+ ;;
+
+ -m)
+ mode=$2
+ shift; shift
+ ;;
+
+ -g)
+ group=$2
+ shift ; shift
+ ;;
+
+ -*)
+ echo "install: unknown option $1"
+ exit
+ ;;
+
+ *)
+ break
+ ;;
+ esac
+done
+#
+# we need two more: filename and destination
+#
+if [ $# -ne 2 ]; then
+ echo "Usage: install [ -o owner ] [ -m mode ] [ -g group ] file destination"
+ exit
+fi
+#
+# first, copy
+#
+cp $1 $2
+#
+# normalize the name
+#
+dest=$2
+if [ -d $2 ]; then
+ dest=$2/`basename $1`
+fi
+#
+# do optional things
+#
+if [ "$owner" ]; then
+ chown $owner $dest
+fi
+if [ "$group" ]; then
+ chgrp $group $dest
+fi
+if [ "$mode" ]; then
+ chmod $mode $dest
+fi
OpenPOWER on IntegriCloud