Quit: Changed warnings and errors to single-line for cleaner filtering.
This commit is contained in:
		
							parent
							
								
									6ec2444891
								
							
						
					
					
						commit
						ddf9544239
					
				
							
								
								
									
										13
									
								
								backup.sh
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								backup.sh
									
									
									
									
									
								
							@ -26,23 +26,22 @@ function scriptHelp {
 | 
				
			|||||||
function quit {
 | 
					function quit {
 | 
				
			||||||
    # list generated warnings, if any
 | 
					    # list generated warnings, if any
 | 
				
			||||||
    if [ ${#exitWarn[@]} -gt 0 ]; then
 | 
					    if [ ${#exitWarn[@]} -gt 0 ]; then
 | 
				
			||||||
        echo -e "${yellow}${stamp} Script generated the following" \
 | 
					        echo -e "${bold}${yellow}Script generated the following" \
 | 
				
			||||||
            "warnings:${normal}" >> "$logFile"
 | 
					            "warnings:${normal}" >> "$logFile"
 | 
				
			||||||
        for warn in "${exitWarn[@]}"; do
 | 
					        for warn in "${exitWarn[@]}"; do
 | 
				
			||||||
            echo -e "   ${ltYellow}${warn}: ${warningExplain[$warn]}${normal}" \
 | 
					            echo -e "${yellow}-- [WARNING] ${warningExplain[$warn]}" \
 | 
				
			||||||
                >> "$logFile"
 | 
					                "(code: ${warn}) --${normal}" >> "$logFile"
 | 
				
			||||||
        done
 | 
					        done
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    if [ -z "$1" ]; then
 | 
					    if [ -z "$1" ]; then
 | 
				
			||||||
        # exit cleanly
 | 
					        # exit cleanly
 | 
				
			||||||
        echo -e "${bold}${green}${stamp} -- [SUCCESS] Script completed" \
 | 
					        echo -e "${bold}${magenta}${stamp} -- Script completed" \
 | 
				
			||||||
            "--$normal" >> "$logFile"
 | 
					            "--$normal" >> "$logFile"
 | 
				
			||||||
        exit 0
 | 
					        exit 0
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        # log error code and exit with said code
 | 
					        # log error code and exit with said code
 | 
				
			||||||
        echo -e "${bold}${red}${stamp} -- [ERROR] Script exited with code $1" \
 | 
					        echo -e "${bold}${red}${stamp} -- [ERROR] ${errorExplain[$1]}" \
 | 
				
			||||||
            " --$normal" >> "$logFile"
 | 
					            "(code: $1) --$normal" >> "$logFile"
 | 
				
			||||||
        echo -e "   ${red}${errorExplain[$1]}$normal" >> "$logFile"
 | 
					 | 
				
			||||||
        exit "$1"
 | 
					        exit "$1"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user