commit 5f4025d141b3d542904898fd2259be753999e9c7 parent 3121d87811b71b31633d4cb0e4d365237857db49 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Mon, 25 Feb 2019 21:55:18 +0100 Use printf to handle special characters in strings Diffstat:
M | links/bin/define | | | 15 | ++++++++------- |
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/links/bin/define b/links/bin/define @@ -48,12 +48,13 @@ while :; do shift done +definition="" for word in "$@"; do - definition="$(define "$word" | remove_comm_msgs)" - if [[ $(echo "$definition" | wc -l) -gt $(tput lines) ]] && \ - [[ "$pager" = 1 ]]; then - echo "$definition" | less - else - echo "$definition" - fi + definition="${definition}\n$(define "$word" | remove_comm_msgs)" done +if [[ $(printf "$definition" | wc -l) -gt $(tput lines) ]] && \ + [[ "$pager" = 1 ]]; then + printf "$definition" | less +else + printf "$definition" +fi