Browse Source

Use sh rather than bash

And fix some bash-isms.
This restores support for BSDs without bash installed.

Reverts 0d57f92.
Closes 21575.
teor 7 years ago
parent
commit
030e2b9817
5 changed files with 14 additions and 15 deletions
  1. 1 1
      chutney
  2. 1 1
      tools/bootstrap-network.sh
  3. 4 5
      tools/hsaddress.sh
  4. 5 5
      tools/test-network.sh
  5. 3 3
      tools/warnings.sh

+ 1 - 1
chutney

@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 set -o errexit
 set -o nounset

+ 1 - 1
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

+ 4 - 5
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"

+ 5 - 5
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

+ 3 - 3
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
 }