Type()
{
if [ -d $1 ]
then
return 1
elif [ -e $1 ]
then
return 2
else
return 0
fi
}
Types()
{
local arg1 arg2
for arg1 in $@
do
arg2=$(Type $arg1)
if [ arg2 -eq 1 ]
then
echo "$arg1 est un répertoire."
elif [ arg2 -eq 2 ]
then
echo "$arg1 n est pas un répertoire."
else
echo "$arg1 ne correspond à aucune entrée du répertoire."
fi
done
}
I don’t know how can I use the function ‘Type’ in ‘Types’. I tried “arg2=$(Type $arg1)” bur it doesn’t seem to work. What’s the correct syntax please ?
If you want to use the function with
$(Type ...), then you can change thereturn ...statements toecho ...(notexec echo ..., which does something else). If you want to keep thereturn ...statements inType(), then you need to do something likeType ...; arg2=$?to test the return code fromType().