From beef0aef02115a59de8c01bb202201b54f2dbdae Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Jun 2022 02:39:22 +0200 Subject: [PATCH] fix(cli): split tput call into two separate calls This fixes an issue where, on some systems, `tput cols lines` does not produce "N\nM" (where N = number of columns in the terminal and M = number of lines), and instead produces "N\n", causing parsing errors. --- bin/doom | 2 +- core/core-cli-lib.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/doom b/bin/doom index e5dda660b..665a57574 100755 --- a/bin/doom +++ b/bin/doom @@ -5,7 +5,7 @@ :; [ -z "$tmpdir" ] && { >&2 echo "Error: failed to run Emacs with command '$EMACS'"; >&2 echo; >&2 echo "Are you sure Emacs is installed and in your \$PATH?"; exit 1; } :; export __DOOMPID="${__DOOMPID:-$$}" :; export __DOOMSTEP="$((__DOOMSTEP+1))" -:; export __DOOMGEOM="${__DOOMGEOM:-`tput cols lines 2>/dev/null`}" +:; export __DOOMGEOM="${__DOOMGEOM:-`tput cols 2>/dev/null`x`tput lines 2>/dev/null`}" :; export __DOOMGPIPE=${__DOOMGPIPE:-$__DOOMPIPE} :; export __DOOMPIPE=; [ -t 0 ] || __DOOMPIPE+=0; [ -t 1 ] || __DOOMPIPE+=1 :; $EMACS -Q --batch --load "$0" -- "$@" || exit=$? diff --git a/core/core-cli-lib.el b/core/core-cli-lib.el index 754f1c7e1..0a5b27c77 100644 --- a/core/core-cli-lib.el +++ b/core/core-cli-lib.el @@ -578,7 +578,7 @@ Throws `doom-cli-invalid-option-error' for illegal values." ;; The geometry of the terminal window. (geometry (when-let* ((geom (getenv "__DOOMGEOM")) ((not (string-blank-p geom))) - (geom (split-string geom "\n"))) + (geom (split-string geom "x"))) (cons (string-to-number (car geom)) (string-to-number (cadr geom))))) ;; Whether the script is being piped into or out of