From nobody@FreeBSD.org  Sun Feb 13 14:45:07 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DE572106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Feb 2011 14:45:07 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id CC8B68FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Feb 2011 14:45:07 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1DEj7qG048668
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Feb 2011 14:45:07 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p1DEj7gm048667;
	Sun, 13 Feb 2011 14:45:07 GMT
	(envelope-from nobody)
Message-Id: <201102131445.p1DEj7gm048667@red.freebsd.org>
Date: Sun, 13 Feb 2011 14:45:07 GMT
From: Alexander Best <arundel@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] install.sh doesn't ignore the -v flag and doesn't honour the -d switch
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         154739
>Category:       misc
>Synopsis:       [patch] install.sh doesn't ignore the -v flag and doesn't honour the -d switch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    uqs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 13 14:50:07 UTC 2011
>Closed-Date:    Sat Jul 02 16:21:15 UTC 2011
>Last-Modified:  Sat Jul 02 16:21:15 UTC 2011
>Originator:     Alexander Best
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD otaku 9.0-CURRENT FreeBSD 9.0-CURRENT #1 r218613M: Sat Feb 12 18:49:57 CET 2011     arundel@otaku:/usr/obj/usr/subversion-src/sys/ARUNDEL  amd64
>Description:
as discussed in [1], this patch will

a) fix install.sh in order to also ignore the -v switch and
b) will allow install.sh to switch to a directory creation mode via the -d flag.

please note that this patch is the work of Eygene Ryabinkin with a few minor tweaks by myself.

cheers.
alex

[1] http://docs.freebsd.org/cgi/mid.cgi?20110203194306.GA55376
>How-To-Repeat:
See [1].
>Fix:


Patch attached with submission follows:

Index: tools/install.sh
===================================================================
--- tools/install.sh	(revision 218217)
+++ tools/install.sh	(working copy)
@@ -29,14 +29,25 @@
 # $FreeBSD$
 
 # parse install's options and ignore them completely.
+dirmode=""
 while [ $# -gt 0 ]; do
     case $1 in
-    -[bCcMpSs]) shift;;
+    -d) dirmode="YES"; shift;;
+    -[bCcMpSsv]) shift;;
     -[Bfgmo]) shift; shift;;
     -[Bfgmo]*) shift;;
     *) break;
     esac
 done
 
+if [ "$#" -eq 0 ]; then
+	echo "Nothing to do: no files/dirs specified" >&2
+	exit 1
+fi
+
 # the remaining arguments are assumed to be files/dirs only.
-exec install -p $*
+if [ -z "$dirmode" ]; then
+	exec install -p "$@"
+else
+	exec install -d "$@"
+fi


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->uqs 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Sun Feb 13 15:10:43 UTC 2011 
Responsible-Changed-Why:  
Ulrich volunteered to take care of this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154739 

From: Alexander Best <arundel@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: misc/154739: [patch] install.sh doesn't ignore the -v flag and doesn't honour the -d switch
Date: Sun, 13 Feb 2011 15:10:20 +0000

 --zYM0uCDKw75PZbzx
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 here's a revised patch. it adds some more sanity checking against the number of
 arguments supplied and also changes the error messages a bit in order to make
 it more obvios that install.sh is responsible for the error.
 
 to committer: please decide which version you like better or simply combine the
 best of both worlds. ;)
 
 cheers.
 alex
 
 -- 
 a13x
 
 --zYM0uCDKw75PZbzx
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="install.sh.diff"
 
 Index: tools/install.sh
 ===================================================================
 --- tools/install.sh	(revision 218613)
 +++ tools/install.sh	(working copy)
 @@ -29,14 +29,30 @@
  # $FreeBSD$
  
  # parse install's options and ignore them completely.
 +dirmode=""
  while [ $# -gt 0 ]; do
      case $1 in
 -    -[bCcMpSs]) shift;;
 +    -d) dirmode="YES"; shift;;
 +    -[bCcMpSsv]) shift;;
      -[Bfgmo]) shift; shift;;
      -[Bfgmo]*) shift;;
      *) break;
      esac
  done
  
 +if [ "$#" -eq 0 ]; then
 +	echo "$0: no files/dirs specified" >&2
 +	exit 1
 +fi
 +
 +if [ -z "$dirmode" ] && [ "$#" -lt 2 ]; then
 +	echo "$0: no target file specified" >&2
 +	exit 1
 +fi
 +
  # the remaining arguments are assumed to be files/dirs only.
 -exec install -p $*
 +if [ -z "$dirmode" ]; then
 +	exec install -p "$@"
 +else
 +	exec install -d "$@"
 +fi
 
 --zYM0uCDKw75PZbzx--

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/154739: commit references a PR
Date: Tue, 22 Feb 2011 08:07:25 +0000 (UTC)

 Author: uqs
 Date: Tue Feb 22 08:07:17 2011
 New Revision: 218940
 URL: http://svn.freebsd.org/changeset/base/218940
 
 Log:
   Teach tools/install.sh the -d directory mode.
   
   Sync up with flags understood by install(1) [1], and make install(1)'s
   usage output not hide the clearly documented -M flag.
   
   PR:		misc/154739 [1]
   Submitted by:	arundel
 
 Modified:
   head/tools/install.sh
   head/usr.bin/xinstall/xinstall.c
 
 Modified: head/tools/install.sh
 ==============================================================================
 --- head/tools/install.sh	Tue Feb 22 07:49:51 2011	(r218939)
 +++ head/tools/install.sh	Tue Feb 22 08:07:17 2011	(r218940)
 @@ -29,14 +29,30 @@
  # $FreeBSD$
  
  # parse install's options and ignore them completely.
 +dirmode=""
  while [ $# -gt 0 ]; do
      case $1 in
 -    -[bCcMpSs]) shift;;
 +    -d) dirmode="YES"; shift;;
 +    -[bCcMpSsv]) shift;;
      -[Bfgmo]) shift; shift;;
      -[Bfgmo]*) shift;;
      *) break;
      esac
  done
  
 +if [ "$#" -eq 0 ]; then
 +	echo "$0: no files/dirs specified" >&2
 +	exit 1
 +fi
 +
 +if [ -z "$dirmode" ] && [ "$#" -lt 2 ]; then
 +	echo "$0: no target specified" >&2
 +	exit 1
 +fi
 +
  # the remaining arguments are assumed to be files/dirs only.
 -exec install -p $*
 +if [ -z "$dirmode" ]; then
 +	exec install -p "$@"
 +else
 +	exec install -d "$@"
 +fi
 
 Modified: head/usr.bin/xinstall/xinstall.c
 ==============================================================================
 --- head/usr.bin/xinstall/xinstall.c	Tue Feb 22 07:49:51 2011	(r218939)
 +++ head/usr.bin/xinstall/xinstall.c	Tue Feb 22 08:07:17 2011	(r218940)
 @@ -769,9 +769,9 @@ static void
  usage(void)
  {
  	(void)fprintf(stderr,
 -"usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
 +"usage: install [-bCcMpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
  "               [-o owner] file1 file2\n"
 -"       install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
 +"       install [-bCcMpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
  "               [-o owner] file1 ... fileN directory\n"
  "       install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n");
  	exit(EX_USAGE);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: uqs 
State-Changed-When: Tue Feb 22 08:23:37 UTC 2011 
State-Changed-Why:  
Patched in head, keeping open for MFH reminder. 
Thanks for the submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154739 
State-Changed-From-To: patched->closed 
State-Changed-By: uqs 
State-Changed-When: Sat Jul 2 16:21:14 UTC 2011 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154739 
>Unformatted:
