Patch to start-freenet.sh. Fixes the following issues:
* Improper reliance on bash for echo behavior -- instead, actually TEST
what echo does and use the right stuff. (Borrowed from perl's
Configure script.)
* Offers to download freenet-ext.jar if it doesn't exist, just like
seednodes.ref.
* Fixes omission of double quotes around $@ for safety.
* More robust user input checking ("yes" will work as "y"). This could
still be tightened further, to require a string beginning with Y or N,
but it's probably OK for now.
--
Greg Wooledge | "Truth belongs to everybody."
greg at wooledge.org | - The Red Hot Chili Peppers
http://wooledge.org/~greg/ |
-------------- next part --------------
Index: start-freenet.sh
===================================================================
RCS file: /cvsroot/freenet/freenet/start-freenet.sh,v
retrieving revision 1.24.2.2
diff -u -r1.24.2.2 start-freenet.sh
--- start-freenet.sh 29 Oct 2002 20:49:48 -0000 1.24.2.2
+++ start-freenet.sh 30 Oct 2002 15:36:30 -0000
@@ -1,22 +1,31 @@
#!/bin/sh
-# determine OS
-OS=`uname`
-# some OS use bash as sh, f.ex. Linux
-# other has a real old Bourne Shell, f.ex SunOS/Solaris
-# this is important since they do not behave in the same way
-SH_IS_BASH=0
-if test $OS != "SunOS"
-then
-SH_IS_BASH=1
-fi
+# Check to see whether we use echo -n or echo "\c" to suppress newlines.
+trap 'rm -f /tmp/.echotmp$$; exit 1' 1 2 3 15
+(echo "hi there\c" ; echo " ") >/tmp/.echotmp$$
+case "`cat /tmp/.echotmp$$`" in
+ *c*) n='-n'; c='';;
+ *) n=''; c='\c';;
+esac
+rm -f /tmp/.echotmp$$
+
# and get java implementation too, Sun JDK or Kaffe
JAVA_IMPL=`java -version 2>&1 | head -1 | cut -f1 -d' '`
if test ! -f freenet-ext.jar; then
echo freenet-ext.jar not found. It can be downloaded from
echo http://freenetproject.org/snapshots/freenet-ext.jar
- exit
+ echo
+ echo $n "Would you like me to download it now? [Y/n] $c"
+ read resp
+ case "$resp" in
+ [Nn]*) exit 0;;
+ esac
+ wget http://freenetproject.org/snapshots/freenet-ext.jar
+ if test ! -f freenet-ext.jar; then
+ echo "Sorry, I couldn't download it. Aborting."
+ exit 1
+ fi
fi
CLASSPATH=freenet.jar:freenet-ext.jar:$CLASSPATH
@@ -27,14 +36,12 @@
if test ! -f seednodes.ref; then
echo seednodes.ref not found, would you like to download some seeds
-
echo from http://hawk.freenetproject.org/~freenet4/seednodes.ref?
- # wow, different echos on bash and sh
- if test "$SH_IS_BASH" = "1"; then echo -n "[y/N] "; else echo '[y/N]\c';fi
+ echo $n "[y/N] $c"
read resp
- if test "$resp" = "y" -o "$resp" = "Y"; then
- wget http://hawk.freenetproject.org/~freenet4/seednodes.ref
- fi
+ case "$resp" in
+ [yY]*) wget http://hawk.freenetproject.org/~freenet4/seednodes.ref;;
+ esac
fi
if test ! -f freenet.conf; then
@@ -61,6 +68,6 @@
fi
echo -n "Starting Freenet now: "
-nice -n 10 -- java $JAVA_ARGS freenet.node.Main $@ &
+nice -n 10 -- java $JAVA_ARGS freenet.node.Main "$@" &
echo $! > freenet.pid
echo "Done"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20021030/f1e3b04b/attachment.pgp>