diff options
author | Dave Reisner <dreisner@archlinux.org> | 2013-09-19 17:12:00 -0400 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-09-19 17:39:49 -0400 |
commit | 184ecaf79483bcaf818c7745c9e1c97bbb276111 (patch) | |
tree | eb1ef15043dd6ec99555e65081c569cad965fbe8 /src/systemctl | |
parent | 1e5413f74faa378172d556e5dec35ab55de16bbf (diff) |
systemctl: Avoid ellipsizing when piping output
Diffstat (limited to 'src/systemctl')
-rw-r--r-- | src/systemctl/systemctl.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 62b5616d80..8b9183dcb3 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -72,6 +72,7 @@ static char **arg_types = NULL; static char **arg_states = NULL; static char **arg_properties = NULL; static bool arg_all = false; +static bool original_stdout_is_tty; static enum dependency { DEPENDENCY_FORWARD, DEPENDENCY_REVERSE, @@ -309,7 +310,7 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) { } } - if (!arg_full) { + if (!arg_full && original_stdout_is_tty) { unsigned basic_len; id_len = MIN(max_id_len, 25u); basic_len = 5 + id_len + 5 + active_len + sub_len; @@ -376,7 +377,7 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) { on_active, active_len, u->active_state, sub_len, u->sub_state, off_active, job_count ? job_len + 1 : 0, u->job_id ? u->job_type : ""); - if (!arg_full && arg_no_pager) + if (desc_len > 0) printf("%.*s\n", desc_len, u->description); else printf("%s\n", u->description); @@ -6177,6 +6178,11 @@ int main(int argc, char*argv[]) { log_parse_environment(); log_open(); + /* Explicitly not on_tty() to avoid setting cached value. + * This becomes relevant for piping output which might be + * ellipsized. */ + original_stdout_is_tty = isatty(STDOUT_FILENO); + r = parse_argv(argc, argv); if (r < 0) goto finish; |