[/tmp]$ cat try.ksh
#! /bin/ksh
if [[ -n "$1" ]] ; then
echo '$1'="[$1]"
else
echo '$1' is empty
fi
if [[ -n "$2" ]] ; then
echo '$2'="[$2]"
else
echo '$2' is empty
fi
if [[ -n "$2" ]] ; then
echo '$3'="[$3]"
else
echo '$3' is empty
fi
[/tmp]$ ./try.ksh
$1 is empty
$2 is empty
$3 is empty
[/tmp]$ ./try.ksh 12 " " " "
$1=[12]
$2=[ ]
$3=[ ]
[/tmp]$
if [[ "${option1}" == "purge" && ${option_count} -eq 3 && -n "${option2}" && -n "${option3}" ]]
then
echo " in the purge if block"
else
echo " in the else part of purge since parametrs are empty"
when there are 3 parameters and 2 of them are empty then it needs to go the else part and display the echo message.But it shows the scho message in the first if block.
Can't you just rely on option_count and forget the quote, i mean
just sampleshellscript archive instead of sampleshellscript archive ' ' ' ' ;
Isnt that the simplest way ?