mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
__fish_print_help: Just use $COLUMNS
This had an undocumented internal feature that would pass the tty width along. Instead, just have it read $COLUMNS, which we always define anyway.
This commit is contained in:
@@ -1,11 +1,4 @@
|
|||||||
function __fish_print_help --description "Print help message for the specified fish function or builtin" --argument item
|
function __fish_print_help --description "Print help message for the specified fish function or builtin" --argument item
|
||||||
# special support for builtin_help_get()
|
|
||||||
set -l tty_width 0
|
|
||||||
if test "$item" = "--tty-width"
|
|
||||||
set tty_width $argv[2]
|
|
||||||
set item $argv[3]
|
|
||||||
end
|
|
||||||
|
|
||||||
if test "$item" = '.'
|
if test "$item" = '.'
|
||||||
set item source
|
set item source
|
||||||
end
|
end
|
||||||
@@ -17,22 +10,8 @@ function __fish_print_help --description "Print help message for the specified f
|
|||||||
|
|
||||||
# Render help output, save output into the variable 'help'
|
# Render help output, save output into the variable 'help'
|
||||||
set -l help
|
set -l help
|
||||||
set -l cols
|
set -l cols $COLUMNS
|
||||||
set -l rLL
|
set -l rLL
|
||||||
if test "$tty_width" -gt 0
|
|
||||||
set cols $tty_width
|
|
||||||
else if command test -t 1
|
|
||||||
# We want to simulate `man`'s dynamic line length, because
|
|
||||||
# defaulting to 80 kind of sucks.
|
|
||||||
# Note: using `command test` instead of `test` because `test -t 1`
|
|
||||||
# doesn't seem to work right.
|
|
||||||
# Note: grab the size from the stdout terminal in case it's somehow
|
|
||||||
# different than the stdin of fish.
|
|
||||||
# use fd 3 to copy our stdout because we need to pipe the output of stty
|
|
||||||
begin
|
|
||||||
stty size 0<&3 | read __ cols
|
|
||||||
end 3<&1
|
|
||||||
end
|
|
||||||
if test -n "$cols"
|
if test -n "$cols"
|
||||||
set cols (math $cols - 4) # leave a bit of space on the right
|
set cols (math $cols - 4) # leave a bit of space on the right
|
||||||
set rLL -rLL=$cols[1]n
|
set rLL -rLL=$cols[1]n
|
||||||
|
|||||||
@@ -169,12 +169,6 @@ wcstring builtin_help_get(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||||||
wcstring out;
|
wcstring out;
|
||||||
const wcstring name_esc = escape_string(name, 1);
|
const wcstring name_esc = escape_string(name, 1);
|
||||||
wcstring cmd = format_string(L"__fish_print_help %ls", name_esc.c_str());
|
wcstring cmd = format_string(L"__fish_print_help %ls", name_esc.c_str());
|
||||||
if (!streams.out_is_redirected && isatty(STDOUT_FILENO)) {
|
|
||||||
// since we're using a subshell, __fish_print_help can't tell we're in
|
|
||||||
// a terminal. Tell it ourselves.
|
|
||||||
int cols = common_get_width();
|
|
||||||
cmd = format_string(L"__fish_print_help --tty-width %d %ls", cols, name_esc.c_str());
|
|
||||||
}
|
|
||||||
if (exec_subshell(cmd, lst, false /* don't apply exit status */) >= 0) {
|
if (exec_subshell(cmd, lst, false /* don't apply exit status */) >= 0) {
|
||||||
for (size_t i = 0; i < lst.size(); i++) {
|
for (size_t i = 0; i < lst.size(); i++) {
|
||||||
out.append(lst.at(i));
|
out.append(lst.at(i));
|
||||||
|
|||||||
Reference in New Issue
Block a user