You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hosts_export() {
local grep_args=(-v -e '^#' -e '^$')
# Exclude all enabled hosts from the output.
IFS=$'\n'read -d '' -r -a enabled <"${ENABLED_HOSTS}"foriin"${enabled[@]}";do
grep_args+=(-e "${i}")
done;# Exclude all disabled hosts from the output to prevent duplicates.
IFS=$'\n'read -d '' -r -a disabled <"${DISABLED_HOSTS}"foriin"${disabled[@]}";do
grep_args+=(-e "^${i}$")
done;
remote="$(grep "${grep_args[@]}""${REMOTE_HOSTS}")"# Concatenate the users hosts file, disabled hosts, and the remote hosts# stripped of any enabled hosts.
hosts="$(cat "${USER_HOSTS}""${DISABLED_HOSTS}")"echo"${hosts}"$'\n'"${remote}"
}
This could be reduced in complexity with a single grep command piped to uniq.
The text was updated successfully, but these errors were encountered:
hosts_export
is fairly inefficient:This could be reduced in complexity with a single
grep
command piped touniq
.The text was updated successfully, but these errors were encountered: