Skip to content

Commit 9126425

Browse files
jonasgitster
authored andcommitted
instaweb: Minor cleanups and fixes for potential problems
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d9c8344 commit 9126425

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

git-instaweb.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ browser="`git config --get instaweb.browser`"
1515
port=`git config --get instaweb.port`
1616
module_path="`git config --get instaweb.modulepath`"
1717

18-
conf=$GIT_DIR/gitweb/httpd.conf
18+
conf="$GIT_DIR/gitweb/httpd.conf"
1919

2020
# Defaults:
2121

@@ -32,7 +32,7 @@ start_httpd () {
3232
httpd_only="`echo $httpd | cut -f1 -d' '`"
3333
if case "$httpd_only" in /*) : ;; *) which $httpd_only >/dev/null;; esac
3434
then
35-
$httpd $fqgitdir/gitweb/httpd.conf
35+
$httpd "$fqgitdir/gitweb/httpd.conf"
3636
else
3737
# many httpds are installed in /usr/sbin or /usr/local/sbin
3838
# these days and those are not in most users $PATHs
@@ -146,14 +146,14 @@ server.pid-file = "$fqgitdir/pid"
146146
cgi.assign = ( ".cgi" => "" )
147147
mimetype.assign = ( ".css" => "text/css" )
148148
EOF
149-
test "$local" = true && echo 'server.bind = "127.0.0.1"' >> "$conf"
149+
test x"$local" = xtrue && echo 'server.bind = "127.0.0.1"' >> "$conf"
150150
}
151151

152152
apache2_conf () {
153153
test -z "$module_path" && module_path=/usr/lib/apache2/modules
154154
mkdir -p "$GIT_DIR/gitweb/logs"
155155
bind=
156-
test "$local" = true && bind='127.0.0.1:'
156+
test x"$local" = xtrue && bind='127.0.0.1:'
157157
echo 'text/css css' > $fqgitdir/mime.types
158158
cat > "$conf" <<EOF
159159
ServerName "git-instaweb"
@@ -206,7 +206,7 @@ EOF
206206
}
207207

208208
script='
209-
s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";#
209+
s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'$(dirname "$fqgitdir")'";#
210210
s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";#
211211
s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;#
212212
s#\(my\|our\) $git_temp =.*#\1 $git_temp = "'$fqgitdir/gitweb/tmp'";#'
@@ -226,8 +226,8 @@ gitweb_css () {
226226
EOFGITWEB
227227
}
228228

229-
gitweb_cgi $GIT_DIR/gitweb/gitweb.cgi
230-
gitweb_css $GIT_DIR/gitweb/gitweb.css
229+
gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
230+
gitweb_css "$GIT_DIR/gitweb/gitweb.css"
231231

232232
case "$httpd" in
233233
*lighttpd*)
@@ -243,6 +243,5 @@ case "$httpd" in
243243
esac
244244

245245
start_httpd
246-
test -z "$browser" && browser=echo
247246
url=http://127.0.0.1:$port
248-
$browser $url || echo $url
247+
"$browser" $url || echo $url

0 commit comments

Comments
 (0)