git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku.dk>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] instaweb: Minor cleanups and fixes for potential problems
Date: Fri, 9 Nov 2007 00:21:42 +0100	[thread overview]
Message-ID: <20071108232142.GA5082@diku.dk> (raw)
In-Reply-To: <20071108154940.GA20988@diku.dk>

Fix path quoting and test of empty values that some shells do not like.
Remove duplicate check and setting of $browser.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 git-instaweb.sh |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

 Here is a new version that has some more fixes so that git-instaweb now
 runs from inside a repository with spaces in the path.

diff --git a/git-instaweb.sh b/git-instaweb.sh
index f05884c..375f2f3 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -27,7 +27,7 @@ browser="`git config --get instaweb.browser`"
 port=`git config --get instaweb.port`
 module_path="`git config --get instaweb.modulepath`"
 
-conf=$GIT_DIR/gitweb/httpd.conf
+conf="$GIT_DIR/gitweb/httpd.conf"
 
 # Defaults:
 
@@ -44,7 +44,7 @@ start_httpd () {
 	httpd_only="`echo $httpd | cut -f1 -d' '`"
 	if case "$httpd_only" in /*) : ;; *) which $httpd_only >/dev/null;; esac
 	then
-		$httpd $fqgitdir/gitweb/httpd.conf
+		$httpd "$fqgitdir/gitweb/httpd.conf"
 	else
 		# many httpds are installed in /usr/sbin or /usr/local/sbin
 		# these days and those are not in most users $PATHs
@@ -158,7 +158,7 @@ EOF
 :DirectoryIndex: ["gitweb.cgi"]
 :PidFile: "$fqgitdir/pid"
 EOF
-	test "$local" = true && echo ':BindAddress: "127.0.0.1"' >> "$conf"
+	test x"$local" = xtrue && echo ':BindAddress: "127.0.0.1"' >> "$conf"
 }
 
 lighttpd_conf () {
@@ -171,14 +171,14 @@ server.pid-file = "$fqgitdir/pid"
 cgi.assign = ( ".cgi" => "" )
 mimetype.assign = ( ".css" => "text/css" )
 EOF
-	test "$local" = true && echo 'server.bind = "127.0.0.1"' >> "$conf"
+	test x"$local" = xtrue && echo 'server.bind = "127.0.0.1"' >> "$conf"
 }
 
 apache2_conf () {
 	test -z "$module_path" && module_path=/usr/lib/apache2/modules
 	mkdir -p "$GIT_DIR/gitweb/logs"
 	bind=
-	test "$local" = true && bind='127.0.0.1:'
+	test x"$local" = xtrue && bind='127.0.0.1:'
 	echo 'text/css css' > $fqgitdir/mime.types
 	cat > "$conf" <<EOF
 ServerName "git-instaweb"
@@ -231,7 +231,7 @@ EOF
 }
 
 script='
-s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";#
+s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'$(dirname "$fqgitdir")'";#
 s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";#
 s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;#
 s#\(my\|our\) $git_temp =.*#\1 $git_temp = "'$fqgitdir/gitweb/tmp'";#'
@@ -251,8 +251,8 @@ gitweb_css () {
 EOFGITWEB
 }
 
-gitweb_cgi $GIT_DIR/gitweb/gitweb.cgi
-gitweb_css $GIT_DIR/gitweb/gitweb.css
+gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
+gitweb_css "$GIT_DIR/gitweb/gitweb.css"
 
 case "$httpd" in
 *lighttpd*)
@@ -271,6 +271,5 @@ webrick)
 esac
 
 start_httpd
-test -z "$browser" && browser=echo
 url=http://127.0.0.1:$port
-$browser $url || echo $url
+"$browser" $url || echo $url
-- 
1.5.3.5.1623.gabaff-dirty

-- 
Jonas Fonseca

      reply	other threads:[~2007-11-09  1:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08 15:49 [PATCH] instaweb: Minor cleanups and fixes for potential problems Jonas Fonseca
2007-11-08 23:21 ` Jonas Fonseca [this message]

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=20071108232142.GA5082@diku.dk \
    --to=fonseca@diku.dk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).