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