Re: [PATCH] instaweb: if no httpd is specified and lighttpd doesn't exist, fall back on apache2.

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] instaweb: if no httpd is specified and lighttpd doesn't exist, fall back on apache2.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:35

nathan spindel [off-list ref] writes:
quoted hunk
Signed-off-by: nathan spindel <redacted>
---
 git-instaweb.sh |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 6f91c8f..b744133 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -31,8 +31,16 @@ conf="$GIT_DIR/gitweb/httpd.conf"
 
 # Defaults:
 
-# if installed, it doesn't need further configuration (module_path)
-test -z "$httpd" && httpd='lighttpd -f'
+# use lighttpd if it exists, otherwise use apache2
+if test -z "$httpd"
+then
+	if type "lighttpd" > /dev/null 2>&1;
The exit code from "type" is very loosely defined by POSIX which just says
it exits >0 to signal that "an error occured".  Presumably it means there
is no such command that is executable on the $PATH, and it may be more
portable and reliable than using "which", but this still worries me.

Doesn't "lighttpd" have an option that reports "I am here" and exit 0,
e.g. "--version"?  Then we could instead say:

	if lighttpd --version >/dev/null
        then
        	... use it ...

and that would be much nicer...

Re: [PATCH] instaweb: if no httpd is specified and lighttpd doesn't exist, fall back on apache2.

From: nathan spindel <hidden>
Date: 2016-06-15 22:44:35

On May 10, 2008, at 11:44 PM, Junio C Hamano wrote:
nathan spindel [off-list ref] writes:
quoted
Signed-off-by: nathan spindel <redacted>
---
git-instaweb.sh |   12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 6f91c8f..b744133 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -31,8 +31,16 @@ conf="$GIT_DIR/gitweb/httpd.conf"
# Defaults:

-# if installed, it doesn't need further configuration (module_path)
-test -z "$httpd" && httpd='lighttpd -f'
+# use lighttpd if it exists, otherwise use apache2
+if test -z "$httpd"
+then
+	if type "lighttpd" > /dev/null 2>&1;
The exit code from "type" is very loosely defined by POSIX which  
just says
it exits >0 to signal that "an error occured".  Presumably it means  
there
is no such command that is executable on the $PATH, and it may be more
portable and reliable than using "which", but this still worries me.

Doesn't "lighttpd" have an option that reports "I am here" and exit 0,
e.g. "--version"?  Then we could instead say:

	if lighttpd --version >/dev/null
       then
       	... use it ...

and that would be much nicer...
I didn't know that the portability of "type" was questionable.  That's  
a good idea.  Thanks!

Re: [PATCH] instaweb: if no httpd is specified and lighttpd doesn't exist, fall back on apache2.

From: nathan spindel <hidden>
Date: 2016-06-15 22:44:35

On May 10, 2008, at 11:44 PM, Junio C Hamano wrote:
nathan spindel [off-list ref] writes:
quoted
Signed-off-by: nathan spindel <redacted>
---
git-instaweb.sh |   12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 6f91c8f..b744133 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -31,8 +31,16 @@ conf="$GIT_DIR/gitweb/httpd.conf"
# Defaults:

-# if installed, it doesn't need further configuration (module_path)
-test -z "$httpd" && httpd='lighttpd -f'
+# use lighttpd if it exists, otherwise use apache2
+if test -z "$httpd"
+then
+	if type "lighttpd" > /dev/null 2>&1;
The exit code from "type" is very loosely defined by POSIX which  
just says
it exits >0 to signal that "an error occured".  Presumably it means  
there
is no such command that is executable on the $PATH, and it may be more
portable and reliable than using "which", but this still worries me.

Doesn't "lighttpd" have an option that reports "I am here" and exit 0,
e.g. "--version"?  Then we could instead say:

	if lighttpd --version >/dev/null
       then
       	... use it ...

and that would be much nicer...
Actually, this approach has the same problem that's worked around  
here: <http://repo.or.cz/w/git.git?a=blob;f=git- 
instaweb.sh;hb=HEAD#l46>. (You might have lighttpd installed but not  
be on your $PATH, which the script should handle for you).

It seems the best approach would be to function-ize the aforementioned  
httpd-path-checking logic [that currently uses "which"] and use it for  
(a) detecting if lighttpd is installed and (b) looking for apache2  
binaries named httpd.

I think for now these particular patches will continue to use "type"  
as you somewhat suggested earlier today.  :)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help