#! /bin/sh
envname=$1
if [ "${envname}" =""]; then
echo usage : `basename $0` envname
exit -1
fi
can someone explain what exactly this does
#! /bin/sh
envname=$1
if [ "${envname}" =""]; then
echo usage : `basename $0` envname
exit -1
fi
can someone explain what exactly this does
When you invoke a script
myscritpname.sh arg1 arg2
you can enter whatever arguments you want, whether the script likes it or not.
This script will tell you if the number of arguments you gave it is not equal to 1
First it sets envame = parameter #1
Then it tests to see if the envanme variable is "empty". If the variable is empty the script print a message
showing the correct usage of the script, then exits with error status.
FWIW the correct way to do this in modern POSIX shells is:
if [ -z $envname ] ; then
echo usage : `basename $0` envname
exit -1
fi