xref: /JGit/org.eclipse.jgit.pgm/jgit.sh (revision 0a39fb2ab65dfdbfbf8022cfdfc3975eba7ac6f2)
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
44*0a39fb2aSShawn O. Pearcecmd=
45*0a39fb2aSShawn O. Pearcefor a in "$@"
46*0a39fb2aSShawn O. Pearcedo
47*0a39fb2aSShawn O. Pearce	case "$a" in
48*0a39fb2aSShawn O. Pearce	-*) continue ;;
49*0a39fb2aSShawn O. Pearce	*)  cmd=$a; break; ;;
50*0a39fb2aSShawn O. Pearce	esac
51*0a39fb2aSShawn O. Pearcedone
52*0a39fb2aSShawn O. Pearce
53*0a39fb2aSShawn O. Pearceuse_pager=
54*0a39fb2aSShawn O. Pearcecase "$cmd" in
55*0a39fb2aSShawn O. Pearcediff)     use_pager=1 ;;
56*0a39fb2aSShawn O. Pearcelog)      use_pager=1 ;;
57*0a39fb2aSShawn O. Pearceesac
58dad52baaSShawn O. Pearce
59dad52baaSShawn O. Pearcethis_script=`which "$0" 2>/dev/null`
60dad52baaSShawn O. Pearce[ $? -gt 0 -a -f "$0" ] && this_script="$0"
61dad52baaSShawn O. Pearcecp=$this_script
62dad52baaSShawn O. Pearce
63dad52baaSShawn O. Pearceif [ -n "$JGIT_CLASSPATH" ]
64dad52baaSShawn O. Pearcethen
65dad52baaSShawn O. Pearce	cp="$cp:$JGIT_CLASSPATH"
66dad52baaSShawn O. Pearcefi
67dad52baaSShawn O. Pearce
68dad52baaSShawn O. Pearce# Cleanup paths for Cygwin.
69dad52baaSShawn O. Pearce#
70dad52baaSShawn O. Pearcecase "`uname`" in
71dad52baaSShawn O. PearceCYGWIN*)
72dad52baaSShawn O. Pearce	cp=`cygpath --windows --mixed --path "$cp"`
73dad52baaSShawn O. Pearce	;;
74dad52baaSShawn O. PearceDarwin)
75*0a39fb2aSShawn O. Pearce	if [ -e /System/Library/Frameworks/JavaVM.framework ]
76dad52baaSShawn O. Pearce	then
77dad52baaSShawn O. Pearce		java_args='
78dad52baaSShawn O. Pearce			-Dcom.apple.mrj.application.apple.menu.about.name=JGit
79dad52baaSShawn O. Pearce			-Dcom.apple.mrj.application.growbox.intrudes=false
80dad52baaSShawn O. Pearce			-Dapple.laf.useScreenMenuBar=true
81dad52baaSShawn O. Pearce			-Xdock:name=JGit
82dad52baaSShawn O. Pearce		'
83dad52baaSShawn O. Pearce	fi
84dad52baaSShawn O. Pearce	;;
85dad52baaSShawn O. Pearceesac
86dad52baaSShawn O. Pearce
87dad52baaSShawn O. PearceCLASSPATH="$cp"
88dad52baaSShawn O. Pearceexport CLASSPATH
89dad52baaSShawn O. Pearce
90dad52baaSShawn O. Pearcejava=java
91*0a39fb2aSShawn O. Pearceif [ -n "$JAVA_HOME" ]
92dad52baaSShawn O. Pearcethen
93dad52baaSShawn O. Pearce	java="$JAVA_HOME/bin/java"
94dad52baaSShawn O. Pearcefi
95dad52baaSShawn O. Pearce
96*0a39fb2aSShawn O. Pearceif [ -n "$use_pager" ]
97*0a39fb2aSShawn O. Pearcethen
98*0a39fb2aSShawn O. Pearce	use_pager=${GIT_PAGER:-${PAGER:-less}}
99*0a39fb2aSShawn O. Pearce	[ cat = "$use_pager" ] && use_pager=
100*0a39fb2aSShawn O. Pearcefi
101*0a39fb2aSShawn O. Pearce
102*0a39fb2aSShawn O. Pearceif [ -n "$use_pager" ]
103*0a39fb2aSShawn O. Pearcethen
104*0a39fb2aSShawn O. Pearce	LESS=${LESS:-FSRX}
105*0a39fb2aSShawn O. Pearce	export LESS
106*0a39fb2aSShawn O. Pearce
107*0a39fb2aSShawn O. Pearce	"$java" $java_args org.eclipse.jgit.pgm.Main "$@" | $use_pager
108*0a39fb2aSShawn O. Pearce	exit
109*0a39fb2aSShawn O. Pearceelse
110dad52baaSShawn O. Pearce  exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@"
111dad52baaSShawn O. Pearce  exit 1
112*0a39fb2aSShawn O. Pearcefi
113