You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sets the default line length to 80 columns,
sets $COLUMNS from the environment if it's there,
sets line length to 999 if stdout is not a tty, for redirected output.
i'd attach it as a patch file, but github doesn't seem to have any way to attach
files to an issue.
--- zpool_main.c.orig 2012-03-27 08:41:19.884741258 +1100
+++ zpool_main.c 2012-03-27 10:11:11.528655924 +1100
@@ -84,6 +84,8 @@
static int zpool_do_get(int, char **);
static int zpool_do_set(int, char **);
+static int tty_columns = 80;
+
/*
* These libumem hooks provide a reasonable set of defaults for the allocator's
* debugging facilities.
@@ -2191,13 +2193,14 @@
}
/*
- * The width must fall into the range [10,38]. The upper limit is the
- * maximum we can have and still fit in 80 columns.
+ * The width must be at least 10, but <= tty_columns - 42
+ * so that we can still fit in one line.
*/
+
if (cb->cb_namewidth < 10)
cb->cb_namewidth = 10;
- if (cb->cb_namewidth > 38)
- cb->cb_namewidth = 38;
+ if (cb->cb_namewidth > tty_columns - 42)
+ cb->cb_namewidth = tty_columns -42;
return (0);
}
@@ -4713,12 +4716,22 @@
int ret;
int i = 0;
char *cmdname;
+ char* env_columns;
(void) setlocale(LC_ALL, "");
(void) textdomain(TEXT_DOMAIN);
opterr = 0;
+ env_columns = getenv("COLUMNS");
+
+ if (env_columns != NULL) {
+ tty_columns = atoi(env_columns);
+ } else {
+ if (!isatty(fileno(stdout)))
+ tty_columns = 999;
+ }
+
/*
* Make sure the user has specified some command.
*/
That makes the output columns line up properly in a wide terminal or when redirecting output to a file, like this:
(this looks better - perfect - on a terminal. github text input fields aren't wide enough)
Initialize dummy_lock to fix the build error in gcc 7.1.1 with:
error: ‘dummy_lock’ is used uninitialized in this function
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closesopenzfs#622
The hard-coded 80 column output makes the output difficult to read when you have long device names in your pools (e.g. /dev/disk/by-id device names).
e.g.
here's a patch for zpool_main.c which:
sets the default line length to 80 columns,
sets $COLUMNS from the environment if it's there,
sets line length to 999 if stdout is not a tty, for redirected output.
i'd attach it as a patch file, but github doesn't seem to have any way to attach
files to an issue.
That makes the output columns line up properly in a wide terminal or when redirecting output to a file, like this:
(this looks better - perfect - on a terminal. github text input fields aren't wide enough)
The text was updated successfully, but these errors were encountered: