xref: /JGit/org.eclipse.jgit.pgm/jgit.sh (revision a5f5b20dff63f30aba69437f4c2386d96072daff)
1dad52baaSShawn O. Pearce#!/bin/sh
2dad52baaSShawn O. Pearce# Copyright (C) 2008-2009, Google Inc.
3dad52baaSShawn O. Pearce# Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
4dad52baaSShawn O. Pearce# and other copyright owners as documented in the project's IP log.
5dad52baaSShawn O. Pearce#
6dad52baaSShawn O. Pearce# This program and the accompanying materials are made available
7dad52baaSShawn O. Pearce# under the terms of the Eclipse Distribution License v1.0 which
8dad52baaSShawn O. Pearce# accompanies this distribution, is reproduced below, and is
9dad52baaSShawn O. Pearce# available at http://www.eclipse.org/org/documents/edl-v10.php
10dad52baaSShawn O. Pearce#
11dad52baaSShawn O. Pearce# All rights reserved.
12dad52baaSShawn O. Pearce#
13dad52baaSShawn O. Pearce# Redistribution and use in source and binary forms, with or
14dad52baaSShawn O. Pearce# without modification, are permitted provided that the following
15dad52baaSShawn O. Pearce# conditions are met:
16dad52baaSShawn O. Pearce#
17dad52baaSShawn O. Pearce# - Redistributions of source code must retain the above copyright
18dad52baaSShawn O. Pearce#   notice, this list of conditions and the following disclaimer.
19dad52baaSShawn O. Pearce#
20dad52baaSShawn O. Pearce# - Redistributions in binary form must reproduce the above
21dad52baaSShawn O. Pearce#   copyright notice, this list of conditions and the following
22dad52baaSShawn O. Pearce#   disclaimer in the documentation and/or other materials provided
23dad52baaSShawn O. Pearce#   with the distribution.
24dad52baaSShawn O. Pearce#
25dad52baaSShawn O. Pearce# - Neither the name of the Eclipse Foundation, Inc. nor the
26dad52baaSShawn O. Pearce#   names of its contributors may be used to endorse or promote
27dad52baaSShawn O. Pearce#   products derived from this software without specific prior
28dad52baaSShawn O. Pearce#   written permission.
29dad52baaSShawn O. Pearce#
30dad52baaSShawn O. Pearce# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
31dad52baaSShawn O. Pearce# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
32dad52baaSShawn O. Pearce# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33dad52baaSShawn O. Pearce# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34dad52baaSShawn O. Pearce# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
35dad52baaSShawn O. Pearce# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36dad52baaSShawn O. Pearce# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37dad52baaSShawn O. Pearce# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38dad52baaSShawn O. Pearce# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
39dad52baaSShawn O. Pearce# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40dad52baaSShawn O. Pearce# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41dad52baaSShawn O. Pearce# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
42dad52baaSShawn O. Pearce# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43dad52baaSShawn O. Pearce
440a39fb2aSShawn O. Pearcecmd=
450a39fb2aSShawn O. Pearcefor a in "$@"
460a39fb2aSShawn O. Pearcedo
470a39fb2aSShawn O. Pearce	case "$a" in
480a39fb2aSShawn O. Pearce	-*) continue ;;
490a39fb2aSShawn O. Pearce	*)  cmd=$a; break; ;;
500a39fb2aSShawn O. Pearce	esac
510a39fb2aSShawn O. Pearcedone
520a39fb2aSShawn O. Pearce
530a39fb2aSShawn O. Pearceuse_pager=
540a39fb2aSShawn O. Pearcecase "$cmd" in
55*a5f5b20dSShawn O. Pearceblame)    use_pager=1 ;;
560a39fb2aSShawn O. Pearcediff)     use_pager=1 ;;
570a39fb2aSShawn O. Pearcelog)      use_pager=1 ;;
580a39fb2aSShawn O. Pearceesac
59dad52baaSShawn O. Pearce
60dad52baaSShawn O. Pearcethis_script=`which "$0" 2>/dev/null`
61dad52baaSShawn O. Pearce[ $? -gt 0 -a -f "$0" ] && this_script="$0"
62dad52baaSShawn O. Pearcecp=$this_script
63dad52baaSShawn O. Pearce
64dad52baaSShawn O. Pearceif [ -n "$JGIT_CLASSPATH" ]
65dad52baaSShawn O. Pearcethen
66dad52baaSShawn O. Pearce	cp="$cp:$JGIT_CLASSPATH"
67dad52baaSShawn O. Pearcefi
68dad52baaSShawn O. Pearce
69dad52baaSShawn O. Pearce# Cleanup paths for Cygwin.
70dad52baaSShawn O. Pearce#
71dad52baaSShawn O. Pearcecase "`uname`" in
72dad52baaSShawn O. PearceCYGWIN*)
73dad52baaSShawn O. Pearce	cp=`cygpath --windows --mixed --path "$cp"`
74dad52baaSShawn O. Pearce	;;
75dad52baaSShawn O. PearceDarwin)
760a39fb2aSShawn O. Pearce	if [ -e /System/Library/Frameworks/JavaVM.framework ]
77dad52baaSShawn O. Pearce	then
78dad52baaSShawn O. Pearce		java_args='
79dad52baaSShawn O. Pearce			-Dcom.apple.mrj.application.apple.menu.about.name=JGit
80dad52baaSShawn O. Pearce			-Dcom.apple.mrj.application.growbox.intrudes=false
81dad52baaSShawn O. Pearce			-Dapple.laf.useScreenMenuBar=true
82dad52baaSShawn O. Pearce			-Xdock:name=JGit
83dad52baaSShawn O. Pearce		'
84dad52baaSShawn O. Pearce	fi
85dad52baaSShawn O. Pearce	;;
86dad52baaSShawn O. Pearceesac
87dad52baaSShawn O. Pearce
88dad52baaSShawn O. PearceCLASSPATH="$cp"
89dad52baaSShawn O. Pearceexport CLASSPATH
90dad52baaSShawn O. Pearce
91dad52baaSShawn O. Pearcejava=java
920a39fb2aSShawn O. Pearceif [ -n "$JAVA_HOME" ]
93dad52baaSShawn O. Pearcethen
94dad52baaSShawn O. Pearce	java="$JAVA_HOME/bin/java"
95dad52baaSShawn O. Pearcefi
96dad52baaSShawn O. Pearce
970a39fb2aSShawn O. Pearceif [ -n "$use_pager" ]
980a39fb2aSShawn O. Pearcethen
990a39fb2aSShawn O. Pearce	use_pager=${GIT_PAGER:-${PAGER:-less}}
1000a39fb2aSShawn O. Pearce	[ cat = "$use_pager" ] && use_pager=
1010a39fb2aSShawn O. Pearcefi
1020a39fb2aSShawn O. Pearce
1030a39fb2aSShawn O. Pearceif [ -n "$use_pager" ]
1040a39fb2aSShawn O. Pearcethen
1050a39fb2aSShawn O. Pearce	LESS=${LESS:-FSRX}
1060a39fb2aSShawn O. Pearce	export LESS
1070a39fb2aSShawn O. Pearce
1080a39fb2aSShawn O. Pearce	"$java" $java_args org.eclipse.jgit.pgm.Main "$@" | $use_pager
1090a39fb2aSShawn O. Pearce	exit
1100a39fb2aSShawn O. Pearceelse
111dad52baaSShawn O. Pearce  exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@"
112dad52baaSShawn O. Pearce  exit 1
1130a39fb2aSShawn O. Pearcefi
114