Explorar o código

Test script exist.sh created to test existence tests

Jovian (Darkside) %!s(int64=6) %!d(string=hai) anos
pai
achega
c9a6a1db84
Modificáronse 1 ficheiros con 59 adicións e 0 borrados
  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.'