I've been told in php it's preferred to avoid the use of the exit command as much as possible.
Is the same true for bash?
For example is the following
#!/bin/bash
if [ -z $1 ]; then
echo You need to enter the directory you want to backup
else
sourceFile=$1
targetFile=/home/me/Desktop/myBackups/files_$(date +%Y_%m_%d_%s)
tar cvf $targetFile $sourceFile
fi
Preferred to this?
#!/bin/bash
if [ -z $1 ]; then
echo You need to enter the directory you want to backup
exit
fi
sourceFile=$1
targetFile=/home/me/Desktop/myBackups/files_$(date +%Y_%m_%d_%s)
tar cvf $targetFile $sourceFile