Shell scripts are now headed with: env /usr/bin/env bash

This commit is contained in:
Gerhard Rieger 2018-03-28 18:21:31 +02:00
parent 14f3e4fed8
commit fbd72c295d
9 changed files with 21 additions and 17 deletions

View file

@ -61,6 +61,11 @@ porting:
functions and dependend option openssl-method can still be
used when configuring socat with --enable-openssl-method
Shell scripts in socat distribution are now headed with:
#! /usr/bin/env bash
to make them better portable to systems without /bin/bash
Thanks to Maya Rashish for sending a patch
testing:
test.sh: Show a warning when phase-1 (insecure phase) of a security
test fails

3
FAQ
View file

@ -24,8 +24,7 @@ Q: I succeeded to configure and make socat, but ./test.sh says something
like:
./test.sh: No such file or directory
A: You need a bash shell, and its location must be correctly specified in the
first line of test.sh, e.g. /usr/local/bin/bash instead of /bin/bash.
A: You need a bash shell in your executable path (locations in $PATH)
Q: configure disables readline / openssl / libwrap support because it does not

View file

@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
# source: proxy.sh
# Copyright Gerhard Rieger and contributors (see file CHANGES)
# Published under the GNU General Public License V.2, see file COPYING

View file

@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
# source: proxyecho.sh
# Copyright Gerhard Rieger and contributors (see file CHANGES)
# Published under the GNU General Public License V.2, see file COPYING

View file

@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
# source: readline-test.sh
# Copyright Gerhard Rieger and contributors (see file CHANGES)
# Published under the GNU General Public License V.2, see file COPYING

View file

@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
# source: readline.sh
# Copyright Gerhard Rieger and contributors (see file CHANGES)
# Published under the GNU General Public License V.2, see file COPYING

View file

@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
# source: socks4a-echo.sh
#set -vx

View file

@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
# source: socks4echo.sh
# Copyright Gerhard Rieger and contributors (see file CHANGES)

18
test.sh
View file

@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
# source: test.sh
# Copyright Gerhard Rieger and contributors (see file CHANGES)
# Published under the GNU General Public License V.2, see file COPYING
@ -750,7 +750,7 @@ for addr in proxy; do
done
echo $OPTS
# prepare dummy server
$SOCAT tcp-l:$PORT,reuseaddr,crlf exec:"/bin/bash proxyecho.sh" || echo "cannot start proxyecho.sh" >&2 &
$SOCAT tcp-l:$PORT,reuseaddr,crlf exec:"/usr/bin/env bash proxyecho.sh" || echo "cannot start proxyecho.sh" >&2 &
pid=$!
sleep 1
for o in $(filloptionvalues $OPTS|tr ',' ' '); do
@ -1951,7 +1951,7 @@ waitip4proto () {
while [ $timeout -gt 0 ]; do
case "$UNAME" in
Linux) if [ "$SS" ]; then
l=$($SS -n -w -l |grep '^raw .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*')
l=$($SS -n -w -l |grep '^\(raw\|UNCONN\) .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*')
else
l=$(netstat -n -w -l |grep '^raw .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*')
fi ;;
@ -1997,7 +1997,7 @@ waitip6proto () {
case "$UNAME" in
Linux)
if [ "$SS" ]; then
l=$($SS -n -w -l |grep '^raw .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*')
l=$($SS -n -w -l |grep '^\(raw\|UNCONN\) .* \*:'$proto' [ ]*\*:\*')
else
l=$(netstat -n -w -l |grep '^raw[6 ] .* .*:[0-9*]*:'$proto' [ ]*:::\*')
fi ;;
@ -4648,7 +4648,7 @@ te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"; da="$da$($ECHO '\r')"
#CMD2="$TRACE $SOCAT tcp4-l:$PORT,crlf SYSTEM:\"read; read; $ECHO \\\"HTTP/1.0 200 OK\n\\\"; cat\""
CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/bin/bash proxyecho.sh\""
CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/usr/bin/env bash proxyecho.sh\""
CMD="$TRACE $SOCAT $opts - proxy:$LOCALHOST:127.0.0.1:1000,pf=ip4,proxyport=$PORT"
printf "test $F_n $TEST... " $N
eval "$CMD2 2>\"${te}2\" &"
@ -4694,7 +4694,7 @@ te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"; da="$da$($ECHO '\r')"
#CMD2="$TRACE $SOCAT $opts tcp6-l:$PORT,crlf SYSTEM:\"read; read; $ECHO \\\"HTTP/1.0 200 OK\n\\\"; cat\""
CMD2="$TRACE $SOCAT $opts tcp6-l:$PORT,reuseaddr,crlf exec:\"/bin/bash proxyecho.sh\""
CMD2="$TRACE $SOCAT $opts tcp6-l:$PORT,reuseaddr,crlf exec:\"/usr/bin/env bash proxyecho.sh\""
CMD="$TRACE $SOCAT $opts - proxy:$LOCALHOST6:127.0.0.1:1000,proxyport=$PORT"
printf "test $F_n $TEST... " $N
eval "$CMD2 2>\"${te}2\" &"
@ -4928,7 +4928,7 @@ te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"; da="$da$($ECHO '\r')"
#CMD2="$TRACE $SOCAT $opts tcp-l:$PORT,crlf SYSTEM:\"read; read; $ECHO \\\"HTTP/1.0 200 OK\n\\\"; cat\""
CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/bin/bash proxyecho.sh -w 2\""
CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/usr/bin/env bash proxyecho.sh -w 2\""
CMD="$TRACE $SOCAT $opts - proxy:$LOCALHOST:127.0.0.1:1000,pf=ip4,proxyport=$PORT"
printf "test $F_n $TEST... " $N
eval "$CMD2 2>\"${te}1\" &"
@ -6436,10 +6436,10 @@ tp="$td/test$N.pid"
$PRINTF "test $F_n $TEST... " $N
(sleep 1; kill -"$SIG" "$(cat "$tpp")") &
# a simple "system:echo $PPID..." does not work on NetBSD, OpenBSD
#$TRACE $SOCAT $opts echo SYSTEM:'exec /bin/bash -c "echo \$PPID '">$tpp"'; echo \$$ '">$tp; read x\"",nofork 2>"$te"; stat=$?
#$TRACE $SOCAT $opts echo SYSTEM:'exec /usr/bin/env bash -c "echo \$PPID '">$tpp"'; echo \$$ '">$tp; read x\"",nofork 2>"$te"; stat=$?
tsh="$td/test$N.sh"
cat <<EOF >"$tsh"
#! /bin/bash
#! /usr/bin/env bash
echo \$PPID >"$tpp"
echo \$\$ >"$tp"
read x