Merge fix/locale-non-posix-shells into master

commit 8a18bcd346fc146e104f77d3a3362a52db210bc3
Author: Lucien Cartier-Tilet <lucien@phundrak.com>
Date:   Tue Dec 21 00:06:45 2021 +0100

    Change `eshell-info-banner--shell-command-to-string' to function

    `eshell-info-banner--shell-command-to-string' being a macro causes
    problems in at least `eshell-info-banner--get-memory-unix'.
    This commit makes `eshell-info-banner--shell-command-to-string' a
    regular function.

commit 981b42c3f530a314990b0d69a6efa9f0bb4957dc
Author: Lucien Cartier-Tilet <lucien@phundrak.com>
Date:   Mon Dec 20 23:29:17 2021 +0100

    Fix variables preceeding commands on non-POSIX shells

    This commit introduces a fix to run commands only on POSIX-compliant
    shells defined in the new constant `eshell-info-banner--posix-shells'.
    If any is found on the machine, the command will be run through it,
    otherwise it will default to `sh'.

commit 364e0f5189471ca3d568638144c208a255808e76
Author: Lucien Cartier-Tilet <lucien@phundrak.com>
Date:   Mon Dec 20 23:12:15 2021 +0100

    Fix setting locale when the default shell is non-POSIX compliant

    In some cases, the default shell does not accept any environment
    variables preceeding the command, such as:

        LANG=C uptime

    For instance, tcsh on DragonFly BSD reports

        LANG=C: Command not found.

    This commit makes the command run on bash, zsh, or sh.
This commit is contained in:
Lucien Cartier-Tilet 2021-12-21 00:12:41 +01:00
parent 661ae7c87d
commit 36b964a993
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 10 additions and 1 deletions

View File

@ -87,6 +87,9 @@
("11.6" . "macOS Big Sur"))
"Versions of OSX and macOS and their name."))
(defconst eshell-info-banner--posix-shells '("bash" "zsh" "sh")
"List of POSIX-compliant shells to run external commands through.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Custom variables ;
@ -215,7 +218,13 @@ argument. `executable-find's remote argument has the value of
(defun eshell-info-banner--shell-command-to-string (command)
"Execute shell command COMMAND and return its output as a string.
Ensures the command is ran with LANG=C."
(shell-command-to-string (format "LANG=C %s" command)))
(let ((shell (or (seq-find (lambda (shell)
(eshell-info-banner--executable-find shell))
eshell-info-banner--posix-shells)
"sh")))
(with-temp-buffer
(call-process shell nil t nil "-c" (concat "LANG=C " command))
(buffer-string))))
(defun eshell-info-banner--progress-bar-without-prefix (bar-length used total &optional newline)
"Display a progress bar without its prefix.