Default value in bash script
authorLorin Hochstein <lhochstein@netflix.com>
Fri, 13 Jan 2017 05:49:13 +0000 (21:49 -0800)
committerLorin Hochstein <lhochstein@netflix.com>
Fri, 13 Jan 2017 05:49:13 +0000 (21:49 -0800)
ch10/playbooks/library/can_reach_bash

index 0e3fec2..36824b8 100644 (file)
@@ -6,6 +6,12 @@ host=`jq -r .host < $1`
 port=`jq -r .port < $1`
 timeout=`jq -r .timeout < $1`
 
+# Default timeout=3
+
+if [[ $timeout -eq "null" ]]; then
+    timeout=3
+fi
+
 # Check if we can reach the host
 nc -z -w $timeout $host $port