[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Use sh rather than bash



commit 030e2b98173e2177666957abbb2750830e758b12
Author: teor <teor2345@xxxxxxxxx>
Date:   Wed Mar 1 11:05:05 2017 +1100

    Use sh rather than bash
    
    And fix some bash-isms.
    This restores support for BSDs without bash installed.
    
    Reverts 0d57f92.
    Closes 21575.
---
 chutney                    |  2 +-
 tools/bootstrap-network.sh |  2 +-
 tools/hsaddress.sh         |  9 ++++-----
 tools/test-network.sh      | 10 +++++-----
 tools/warnings.sh          |  6 +++---
 5 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/chutney b/chutney
index 0d4b391..f231e66 100755
--- a/chutney
+++ b/chutney
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 set -o errexit
 set -o nounset
diff --git a/tools/bootstrap-network.sh b/tools/bootstrap-network.sh
index 7fb2eed..49afbd8 100755
--- a/tools/bootstrap-network.sh
+++ b/tools/bootstrap-network.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 #
 # 1. potentially stop running network
 # 2. bootstrap a network from scratch as quickly as possible
diff --git a/tools/hsaddress.sh b/tools/hsaddress.sh
index 517c6b5..00645d7 100755
--- a/tools/hsaddress.sh
+++ b/tools/hsaddress.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 #
 # Usage:
 #    tools/hsaddress.sh [hs_node]
@@ -31,12 +31,12 @@ NAME=$(basename "$0")
 DEST="$CHUTNEY_DATA_DIR/nodes"
 TARGET=hidden_service/hostname
 
-function usage() {
+usage() {
     echo "Usage: $NAME [hs_node]"
     exit 1
 }
 
-function show_address() {
+show_address() {
     cat "$1"
 }
 
@@ -54,8 +54,7 @@ then
 elif [ $# -eq 1 ];
 then
     [ -d "$DEST/$1" ] || { echo "$NAME: $1 not found"; exit 1; }
-    # support hOLD
-    [[ "$1" =~ .*h.* ]] || { echo "$NAME: $1 is not a HS"; exit 1; }
+    # we don't check the name of the HS directory, because tags vary
     FILE="$DEST/$1/$TARGET"
     [ -e "$FILE" ] || { echo "$NAME: $FILE not found"; exit 1; }
     show_address "$FILE"
diff --git a/tools/test-network.sh b/tools/test-network.sh
index bf04dd5..0c8d795 100755
--- a/tools/test-network.sh
+++ b/tools/test-network.sh
@@ -1,6 +1,6 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
-export ECHO=${ECHO:-"echo"}
+export ECHO="${ECHO:-echo}"
 
 # Output is prefixed with the name of the script
 myname=$(basename "$0")
@@ -246,9 +246,9 @@ if [ "$NETWORK_DRY_RUN" = true -o "$CHUTNEY_WARNINGS_ONLY" = true ]; then
     if [ "$CHUTNEY_WARNINGS_ONLY" = true ]; then
         "$WARNINGS"
     fi
-    # we can't exit here, it breaks argument processing
-    # this only works in bash: return semantics are shell-specific
-    return 2>/dev/null || exit
+    # This breaks sourcing this script: that is intentional, as the previous
+    # behaviour only worked with bash as /bin/sh
+    exit
 fi
 
 "$CHUTNEY_PATH/tools/bootstrap-network.sh" "$NETWORK_FLAVOUR" || exit 3
diff --git a/tools/warnings.sh b/tools/warnings.sh
index da17eda..109032b 100755
--- a/tools/warnings.sh
+++ b/tools/warnings.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 #
 # Usage:
 #    tools/warnings.sh [node]
@@ -31,7 +31,7 @@ if [ -d "$PWD/$CHUTNEY_DATA_DIR" ]; then
     export CHUTNEY_DATA_DIR="$PWD/$CHUTNEY_DATA_DIR"
 fi
 
-function show_warnings() {
+show_warnings() {
     # Work out the file and filter settings
     if [ "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
         FILE="$1/*/$LOG_FILE"
@@ -75,7 +75,7 @@ function show_warnings() {
     fi
 }
 
-function usage() {
+usage() {
     echo "Usage: $NAME [node]"
     exit 1
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits