#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2013 Christopher Bratusek		#
#							#
#########################################################

if [[ $(ini_get cdspell) == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"cdspell" $"On"
	dbg_log shopt -s cdspell
else	dbg_msg $"BashStyle-NG Setting:" $"cdspell" $"Off"
	dbg_log shopt -u cdspell
fi

if [[ $(ini_get cdable_vars) == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"cdable_vars" $"On"
	dbg_log shopt -s cdable_vars
else	dbg_msg $"BashStyle-NG Setting:" $"cdable_vars" $"Off"
	dbg_log shopt -u cdable_vars
fi

if [[ $(ini_get checkhash) == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"checkhash" $"On"
	dbg_log shopt -s checkhash
else	dbg_msg $"BashStyle-NG Setting:" $"checkhash" $"Off"
	dbg_log shopt -u checkhash
fi

if [[ $(ini_get cmdhist) == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"cmdhist" $"On"
	dbg_log shopt -s cmdhist
else	dbg_msg $"BashStyle-NG Setting:" $"cmdhist" $"Off"
	dbg_log shopt -u cmdhist
fi

if [[ $(ini_get force_fignore) == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"force_fignore" $"On"
	dbg_log shopt -s force_fignore
else	dbg_msg $"BashStyle-NG Setting:" $"force_fignore" $"Off"
	dbg_log shopt -u force_fignore
fi

if [[ $(ini_get histreedit) == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"histreedit" $"On"
	dbg_log shopt -s histreedit
else	dbg_msg $"BashStyle-NG Setting:" $"histreedit" $"Off"
	dbg_log shopt -u histreedit
fi

if [[ $(ini_get no_empty_cmd_completion) == True ]]; then \
	dbg_msg $"BashStyle-NG Setting:" $"no_empty_cmd_completion" $"On"
	dbg_log shopt -s no_empty_cmd_completion
else	dbg_msg $"BashStyle-NG Setting:" $"no_empty_cmd_completion" $"Off"
	dbg_log shopt -u no_empty_cmd_completion
fi

if [[ $HISTCONTROL != erasedups && $(ini_get histappend) == True ]]; then
	dbg_msg $"BashStyle-NG Setting:" $"histappend" $"On"
	dbg_log shopt -s histappend
else	dbg_msg $"BashStyle-NG Setting:" $"histappend" $"Off"
	dbg_log shopt -u histappend
fi

# Stuff new in Bash 4.0
if [[ ${BASH_VERSINFO[0]} -ge "4" ]]; then

	if [[ $(ini_get autocd) == True ]]; then
		dbg_msg $"BashStyle-NG Setting:" $"autocd" $"On"
		dbg_log shopt -s autocd
	else	dbg_msg $"BashStyle-NG Setting:" $"autocd" $"Off"
		dbg_log shopt -u autocd
	fi

	if [[ $(ini_get checkjobs) == True ]]; then
		dbg_msg $"BashStyle-NG Setting:" $"checkjobs" $"On"
		dbg_log shopt -s checkjobs
	else	dbg_msg $"BashStyle-NG Setting:" $"checkjobs" $"Off"
		dbg_log shopt -u checkjobs
	fi

	if [[ $(ini_get globstar) == True ]]; then
		dbg_msg $"BashStyle-NG Setting:" $"globstar" $"On"
		dbg_log shopt -s globstar
	else	dbg_msg $"BashStyle-NG Setting:" $"globstar" $"Off"
		dbg_log shopt -u globstar
	fi

	if [[ $(ini_get dirspell) == True ]]; then
		dbg_msg $"BashStyle-NG Setting:" $"dirspell" $"On"
		dbg_log shopt -s dirspell
	else	dbg_msg $"BashStyle-NG Setting:" $"dirspell" $"Off"
		dbg_log shopt -u dirspell
	fi
else	dbg_msg $"BashStyle-NG Message: Bash is not 4.x -- disabling new shopts"
fi

# Stuff new in Bash 4.3
if [[ ${BASH_VERSINFO[0]}${BASH_VERSINFO[1]} -ge "43" ]]; then
	if [[ $(ini_get direxpand) == True ]]; then
		dbg_msg $"BashStyle-NG Setting:" $"direxpand" $"On"
		dbg_log shopt -s direxpand
	else	dbg_msg $"BashStyle-NG Setting:" $"direxpand" $"Off"
		dbg_log shopt -u direxpand
	fi
	if [[ $(ini_get globasciirange) == True ]]; then
		dbg_msg $"BashStyle-NG Setting:" $"globasciiranges" $"On"
		dbg_log shopt -s globasciiranges
	else	dbg_msg $"BashStyle-NG Setting:" $"globasciiranges" $"Off"
		dbg_log shopt -u globasciiranges
	fi
else	dbg_msg $"BashStyle-NG Message: Bash is not 4.3+ -- disabling new shopts"
fi
