if [ $YN = “y” ] (Dedicated web hosting) ; then
if [ $YN = “y” ] ; then Making this change, you find that the syntax of the script is okay because the command $ /bin/sh -n buggy1.sh produces no output. Why You Should Use Syntax Checking After looking at the shell script in the previous example, you might be wondering why you couldn’t simply execute the shell script to determine the problem. After all, the command $ /bin/sh ./buggy1.sh produces the output buggy1.sh: syntax error at line 7: ‘fi’ unexpected This output is identical to the output of the following command: $ /bin/sh -n ./buggy1.sh For this script, it does not matter whether you use the syntax checking mode, but this is not always the case. As an example, consider the following script (the line numbers are included for your reference): 1 #!/bin/sh 2 3 Failed() { 4 if [ $1 -ne 0 ] ; then 5 echo “Failed. Exiting.” ; exit 1 ; 6 fi 7 echo “Done.” 8 } 9 10 echo “Deleting old backups, please wait… c” 11 rm -r backup > /dev/null 2>&1 12 Failed $? 13 14 echo “Make backup (y/n)? c” 15 read RESPONSE 16 case $RESPONSE in 17 [yY]|[Yy][Ee][Ss]|*) 18 echo “Making backup, please wait… c” 19 cp -r docs backup 20 Failed 21 [nN]|[Nn][Oo]) 22 echo “Backup Skipped.” ;;
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.