From 15593ed0192e993d5293c91ac73967661217e110 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 12 Jul 2010 17:04:47 -0400 Subject: [PATCH] Just ignore the -c option, it is the default Add support for -d option --HG-- branch : 1.7 --- install-sh | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/install-sh b/install-sh index cf3081f06..c8d2b7023 100755 --- a/install-sh +++ b/install-sh @@ -49,7 +49,7 @@ CHMODIT=false STRIPIT=false BACKIT=false TOUCHIT=true -SAVESRC=false +DIRMODE=false case `${WHOAMI}` in root) @@ -74,7 +74,10 @@ while ${MORETODO} ; do BACKUP=`expr "$1" : '-b\(.*\)'` ;; X-c) - SAVESRC=true + # backwards compatibility + ;; + X-d) + DIRMODE=true ;; X-g) GROUP="$2" @@ -155,31 +158,33 @@ while ${MORETODO} ; do ${MORETODO} && shift done +## Making a directory? +if ${DIRMODE} ; then + while test $# != 0; do + DEST="$1" + if [ ! -d "${DEST}" ] ; then + ${MKDIR} "${DEST}" || exit 1 + fi + if ${CHOWNIT} ; then + ${CHOWN} "${OWNER}" "${DEST}" || exit 1 + fi + if ${CHGROUPIT} ; then + ${CHGRP} "${GROUP}" "${DEST}" || exit 1 + fi + if ${CHMODIT} ; then + ${CHMOD} "${MODE}" "${DEST}" || exit 1 + fi + shift; + done + exit 0 +fi + ## Process arguments. if [ $# -ne 2 ] ; then echo "Usage: ${PROGNAME} [flags] source destination" exit 1 fi -## Making a directory? -if [ X"$1" = X. ] ; then - DEST="$2" - if [ ! -d "${DEST}" ] ; then - ${MKDIR} "${DEST}" || exit 1 - fi - if ${CHOWNIT} ; then - ${CHOWN} "${OWNER}" "${DEST}" || exit 1 - fi - if ${CHGROUPIT} ; then - ${CHGRP} "${GROUP}" "${DEST}" || exit 1 - fi - if ${CHMODIT} ; then - umask 0 - ${CHMOD} "${MODE}" "${DEST}" || exit 1 - fi - exit 0 -fi - ## Get the destination and a temp file in the destination diretory. if [ -d "$2" ] ; then DEST="$2/`basename $1`" @@ -190,7 +195,7 @@ else fi ## If not given the same name, we must try to copy. -if [ X"$1" != X"$2" -o $SAVESRC ] ; then +if [ X"$1" != X"$2" ] ; then if cmp -s "$1" "${DEST}" ; then ## Files are same; touch or not. ${TOUCHIT} && touch "${DEST}" @@ -221,7 +226,6 @@ if ${CHGROUPIT} ; then ${CHGRP} "${GROUP}" "${DEST}" || exit 1 fi if ${CHMODIT} ; then - umask 0 ${CHMOD} "${MODE}" "${DEST}" || exit 1 fi exit 0 -- 2.40.0