Escape newlines consistently.

This commit is contained in:
William Melody 2020-04-12 16:50:30 -07:00
parent 16c7484c17
commit 7b8b4db54b
1 changed files with 10 additions and 10 deletions

20
hosts
View File

@ -420,7 +420,7 @@ _print_entries() {
if [[ "${_parts[0]}" =~ disabled ]] if [[ "${_parts[0]}" =~ disabled ]]
then then
_parts=("${_parts[@]:1}") _parts=("${_parts[@]:1}")
printf "disabled:\n" printf "disabled:\\n"
fi fi
_current_divided=$((${#_parts[0]} / 8)) _current_divided=$((${#_parts[0]} / 8))
@ -774,7 +774,7 @@ backups() {
_timestamp="$(date +"%Y%m%d%H%M%S")" _timestamp="$(date +"%Y%m%d%H%M%S")"
cp "${HOSTS_PATH}" "${HOSTS_PATH}--backup-${_timestamp}" && \ cp "${HOSTS_PATH}" "${HOSTS_PATH}--backup-${_timestamp}" && \
printf "Backed up to %s--backup-%s\n" "${HOSTS_PATH}" "${_timestamp}" printf "Backed up to %s--backup-%s\\n" "${HOSTS_PATH}" "${_timestamp}"
;; ;;
compare) compare)
local _filename local _filename
@ -801,7 +801,7 @@ backups() {
exit 1 exit 1
elif [[ ! -e "${_hosts_dirname}/${_filename}" ]] elif [[ ! -e "${_hosts_dirname}/${_filename}" ]]
then then
printf "Backup not found: %s\n" "${_filename:-}" printf "Backup not found: %s\\n" "${_filename:-}"
exit 1 exit 1
fi fi
@ -820,9 +820,9 @@ backups() {
[[ -e "${_hosts_dirname}/${1:-}" ]] [[ -e "${_hosts_dirname}/${1:-}" ]]
then then
rm "${_hosts_dirname}/${1:-}" && rm "${_hosts_dirname}/${1:-}" &&
printf "Backup deleted: %s\n" "${_hosts_dirname}/${1:-}" printf "Backup deleted: %s\\n" "${_hosts_dirname}/${1:-}"
else else
printf "Backup not found: %s\n" "${1:-}" printf "Backup not found: %s\\n" "${1:-}"
exit 1 exit 1
fi fi
;; ;;
@ -833,7 +833,7 @@ backups() {
exit 1 exit 1
elif [[ ! -e "${_hosts_dirname}/${1}" ]] elif [[ ! -e "${_hosts_dirname}/${1}" ]]
then then
printf "Backup not found: %s\n" "${1:-}" printf "Backup not found: %s\\n" "${1:-}"
exit 1 exit 1
fi fi
@ -845,7 +845,7 @@ backups() {
fi fi
cat "${_hosts_dirname}/${1}" > "${HOSTS_PATH}" && cat "${_hosts_dirname}/${1}" > "${HOSTS_PATH}" &&
printf "Restored from backup: %s\n" "${1}" printf "Restored from backup: %s\\n" "${1}"
;; ;;
show) show)
if [[ -z "${1:-}" ]] if [[ -z "${1:-}" ]]
@ -854,7 +854,7 @@ backups() {
exit 1 exit 1
elif [[ ! -e "${_hosts_dirname}/${1}" ]] elif [[ ! -e "${_hosts_dirname}/${1}" ]]
then then
printf "Backup not found: %s\n" "${1:-}" printf "Backup not found: %s\\n" "${1:-}"
exit 1 exit 1
fi fi
@ -878,11 +878,11 @@ backups() {
then then
for __filename in "${_filenames[@]:-}" for __filename in "${_filenames[@]:-}"
do do
printf "%s\n" "${__filename}" printf "%s\\n" "${__filename}"
done done
else else
printf \ printf \
"No backups found. Create a new backup:\n %s backups create\n" \ "No backups found. Create a new backup:\\n %s backups create\\n" \
"${_ME}" "${_ME}"
fi fi
;; ;;