diff options
author | 2014-10-10 00:11:23 -0700 | |
---|---|---|
committer | 2014-10-10 00:11:23 -0700 | |
commit | 76c6985f82a29422c47cdb6c72708493a6248732 (patch) | |
tree | 7b377597f61c9c2966c7664a195098db6b14726d /builtin.cpp | |
parent | ac8c5910eb0fa03b9384463cb2a86ac4f929362e (diff) |
A little extra tweaking so builtin_print_help looks better
The terminal width magic that __fish_print_help learned doesn't help
when builtin_print_help runs it in a subshell. Instead, add an
undocumented --tty-width flag to __fish_print_help that's used to pass
the terminal width.
Diffstat (limited to 'builtin.cpp')
-rw-r--r-- | builtin.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/builtin.cpp b/builtin.cpp index a01c2519..e4f276f9 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -220,7 +220,14 @@ wcstring builtin_help_get(parser_t &parser, const wchar_t *name) wcstring_list_t lst; wcstring out; const wcstring name_esc = escape_string(name, 1); - const 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 (!builtin_out_redirect && isatty(1)) + { + // 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) { for (size_t i=0; i<lst.size(); i++) |