mercredi 24 mai 2017

Bash Losing track of IF Statements

I am making a install wizard, however I have alot of IF Statements, and it keeps confusing me and I get disorientated, Especially when I try to fix something that's wrong with my Script. How to prevent this? Here's my script:

As you can see I have alot if IF Statements. And I can't keep track of them all. Is there a way to like mark or minimize them, like with HTML? I'm using the Atom Text editor.

Or is there a way to reduce the IF Statements?

#!/bin/bash

# Author: GlitchyShadowZ

# Name: NJDTL Install Wizard 1.0

# Date of Last Update:

# Date of LEGACY (Initial Release):
clear
echo "Would you like to start the NJDTL Install Wizard? [y/n]"
read startYN
if [ $startYN == y ]
  then
      echo "Starting Install Wizard. . ."
      mkdir ~/.NJDTL
    fi
    if [ $startYN == n ]
      then
          echo "Are you sure you want to cancel the Install Wizard? [y/n]"
          read CancelConfirm
          if [ $CancelConfirm == y ]
            then
                echo "Cancelling Install. . ."
                exit
              fi
          if [ $CancelConfirm == n ]
            then
                echo "Chose "n". Continuing Installation. . ."
                exec $0
        fi
      fi

[Loading Screen removed for the purpose of this post]

if ! [ -d ~/sbin ]
then
echo "A Bin folder in /home/ is required for this program. Create one? [y/n]"
read BinChoice
  if [ $BinChoice = y ]
    then
      mkdir ~/testbin
    fi
    if [ $BinChoice = n ]
  then
    echo "Without a Bin Folder NJDTL Will not work. Cancelling Install."
  fi

else
  echo "bin folder existent. Continuing Install. . ."
fi
fi

Aucun commentaire:

Enregistrer un commentaire