Browse Source

Test script exist.sh created to test existence tests

Jovian (Darkside) 6 years ago
parent
commit
c9a6a1db84
1 changed files with 59 additions and 0 deletions
  1. 59 0
      exist.sh

+ 59 - 0
exist.sh

@@ -0,0 +1,59 @@
+#!/bin/bash
+# Existence of arg
+echo "[exist] Testing existence."
+if [ -n $1 ]
+then
+	echo 'Arg 1 exists'
+fi
+
+if [ -z $1 ]
+then
+	echo 'Arg 1 does not exist'
+fi
+
+# Existence of prompt
+read -p 'Type > ' var
+if [ -n $var ]
+then
+	echo 'Var exists'
+fi
+
+if [ -z $var ]
+then
+	echo 'Var does not exist'
+fi
+
+# Existance of nothing
+if [ -n $not_declared_variable ]
+then
+	echo 'not_declared_variable exists'
+fi
+
+if [ -z $not_declared_variable ]
+then
+	echo 'not_declared_variable does not exist'
+fi
+
+# Existance of quoted nothing
+if [ -n "$not_declared_quoted_variable" ]
+then
+	echo 'not_declared_quoted_variable exists'
+fi
+
+if [ -z "$not_declared_quoted_variable" ]
+then
+	echo 'not_declared_quoted_variable does not exist'
+fi
+
+# Existance of void
+if [ -n ]
+then
+	echo 'void exists'
+fi
+
+if [ -z ]
+then
+	echo 'void does not exist'
+fi
+
+echo '[exist] End of script.'