From 2cc95ba021f4f295d974f51f5a4349aa370f3317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Thu, 5 Jul 2012 09:24:29 +0200 Subject: [PATCH] using stty and cut (coreutils) instead of tput (ncurses) for getting terminal width --- ponysay | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ponysay b/ponysay index 46c288e3..59583872 100755 --- a/ponysay +++ b/ponysay @@ -66,9 +66,10 @@ say() { if [ "$PONYSAY_FULL_WIDTH" = 'no' ] || [ "$PONYSAY_FULL_WIDTH" = 'n' ] || [ "$PONYSAY_FULL_WIDTH" = '0' ]; then cat else - ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ${HOME}/.local/bin/ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ./ponysaytruncater `tput cols || echo 0` 2>/dev/null || + WIDTH=$((stty size <&2 || echo 0 0) | cut -d ' ' -f 2) + ponysaytruncater $WIDTH 2>/dev/null || + ${HOME}/.local/bin/ponysaytruncater $WIDTH 2>/dev/null || + ./ponysaytruncater $WIDTH 2>/dev/null || cat fi }