[systemd-commits] src/systemctl
Dave Reisner
dreisner at kemper.freedesktop.org
Thu Sep 19 14:40:39 PDT 2013
src/systemctl/systemctl.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 184ecaf79483bcaf818c7745c9e1c97bbb276111
Author: Dave Reisner <dreisner at archlinux.org>
Date: Thu Sep 19 17:12:00 2013 -0400
systemctl: Avoid ellipsizing when piping output
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 62b5616..8b9183d 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;
More information about the systemd-commits
mailing list