(scripts) whitespace remover ..
This commit is contained in:
@@ -4,7 +4,7 @@ function remove-whitespace {
|
||||
# exclude file types
|
||||
# (ignore generated files/directories)
|
||||
exclude_paths=(
|
||||
"*/.git/*"
|
||||
'*/.git/*'
|
||||
)
|
||||
exclude_files=(
|
||||
"*.lst"
|
||||
@@ -20,23 +20,39 @@ function remove-whitespace {
|
||||
unset file_args
|
||||
unset ffunix
|
||||
unset files
|
||||
unset args
|
||||
unset arguments
|
||||
|
||||
for arg in $@; do
|
||||
if [[ "${arg}" =~ ^-[a-zA-Z]{2,}$ ]]; then
|
||||
temp=($(echo ${arg} | grep --color=never -o "."))
|
||||
args+=(${temp[@]/#/-})
|
||||
else
|
||||
args+=("${arg}")
|
||||
fi
|
||||
done
|
||||
|
||||
for arg in ${args[@]}; do
|
||||
[[ "${arg}" != "--" ]] && arguments+=("${arg}")
|
||||
done
|
||||
unset args
|
||||
|
||||
for arg in ${arguments[@]}; do
|
||||
unset arg_found
|
||||
case ${arg} in
|
||||
-*u* | --unix)
|
||||
"-u" | "--unix")
|
||||
arg_found="true"
|
||||
ffunix="true"
|
||||
;;
|
||||
-*h* | --help)
|
||||
"-h" | "--help")
|
||||
arg_found="true"
|
||||
help="true"
|
||||
;;
|
||||
-*n* | --no-action)
|
||||
"-n" | "--no-action")
|
||||
arg_found="true"
|
||||
no_action="true"
|
||||
;;
|
||||
-*s* | --silent)
|
||||
"-s" | "--silent")
|
||||
arg_found="true"
|
||||
silent="true"
|
||||
;;
|
||||
@@ -117,9 +133,16 @@ EOF
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
if [[ -z "${silent} ${no_action}" ]] &&
|
||||
if [[ -n "${no_action}" ]] &&
|
||||
[[ -n "${files}" ]]; then
|
||||
tput setaf 1
|
||||
tput smso
|
||||
echo "The following files contain whitespace:"
|
||||
tput sgr0
|
||||
for file in ${files[@]}; do
|
||||
echo "${file}"
|
||||
done
|
||||
elif [[ -z "${silent}" ]] &&
|
||||
[[ -n "${files}" ]]; then
|
||||
tput setaf 1
|
||||
tput smso
|
||||
@@ -129,4 +152,5 @@ EOF
|
||||
echo "${file}"
|
||||
done
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user