git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Hudec <bulb@ucw.cz>
To: Robert Schiele <rschiele@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] add simple install replacement
Date: Fri, 12 Oct 2007 16:06:47 +0200	[thread overview]
Message-ID: <20071012140647.GC7865@efreet.light.src> (raw)
In-Reply-To: <20071011215237.GI20753@schiele.dyndns.org>

[-- Attachment #1: Type: text/plain, Size: 2881 bytes --]

On Thu, Oct 11, 2007 at 23:52:37 +0200, Robert Schiele wrote:
> This patch adds a very simple install replacement script to git.
> This allows more easy installation on systems that don't have a
> compatible install.

Do you have a particular case where you need it?

> Signed-off-by: Robert Schiele <rschiele@gmail.com>
> ---
>  gitinstall |   35 +++++++++++++++++++++++++++++++++++
>  1 files changed, 35 insertions(+), 0 deletions(-)
>  create mode 100755 gitinstall
> 
> diff --git a/gitinstall b/gitinstall
> new file mode 100755
> index 0000000..8b346d6
> --- /dev/null
> +++ b/gitinstall
> @@ -0,0 +1,35 @@
> +#!/bin/sh
> +
> +MKDIRMODE=0
> +MODE=755
> +while getopts 'dm:' FLAG; do

No such thing here:
zsh$ /bin/sh
$ which getopts
$

Yes, bash and zsh do have that, but my (and I suspect many git users')
/bin/sh is neither of those. Git scripts should use just POSIX shell
features for portability.

Which is particularly important when you are trying to replace a common
utility, because the systems that won't have it are likely to not have bash
either.

You may want to have a look at /usr/share/automake-1.9/install-sh (or
/usr/share/automake<something>/install-sh). It shows how to portably process
options in shell and since it's in fact covered by the MIT/X license (and FSF
changes are public domain), git could just use it if necessary.

> +    case "$FLAG" in
> +        d) MKDIRMODE=1;;
> +        m) MODE="$OPTARG";;
> +	*) exit 1;;
> +    esac
> +done
> +if test "$OPTIND" != 1; then
> +    shift `expr $OPTIND - 1`
> +fi
> +if test $MKDIRMODE = 1; then
> +    mkdir -p "$@"
> +    chmod "$MODE" "$@"
> +else
> +    if test $# = 2 && ! test -d "$2"; then
> +	rm -rf "$2"

Are you sure reall install would do this? The maual (install(1)) states
following usage variants:

    install [OPTION]... [-T] SOURCE DEST
    install [OPTION]... SOURCE... DIRECTORY
    install [OPTION]... -t DIRECTORY SOURCE...
    install [OPTION]... -d DIRECTORY...

Now however there is nothing saying that SOURCE... is at least two, so is

    install git /usr/bin

a case of the first or second usage? I would say the second, but your code
would:

    rm -rf /usr/bin
    cp git /usr/bin

> +	cp "$1" "$2"
> +	chmod "$MODE" "$2"
> +    else
> +	FILES=
> +	while test $# != 1; do
> +	    FILES="$FILES $1"
> +	    shift
> +	done
> +	for i in $FILES; do

    touch "foo*bar" "a b c"
    ./gitinstall "b*c" "a b c" /tmp

... will copy a lot of files to /tmp (presuming we are in git source
directory, where tons of files are called builtin-<something>.c) and complain
that there is no 'a', no 'b' and no 'c'.

> +	    rm -rf "$1/"`basename "$i"`
> +	    cp "$i" "$1"
> +	    chmod "$MODE" "$1/"`basename "$i"`
> +	done
> +    fi
> +fi

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-10-12 14:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-11 21:52 [PATCH] add simple install replacement Robert Schiele
2007-10-12 14:06 ` Jan Hudec [this message]
2007-10-12 15:07   ` Robert Schiele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071012140647.GC7865@efreet.light.src \
    --to=bulb@ucw.cz \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rschiele@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).