From 4403e7edc2743ef6275e1adb82758bd475ac6602 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Fri, 28 Apr 2023 15:48:55 -0400 Subject: [PATCH] ls tty fix --- src/commands/ls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands/ls.c b/src/commands/ls.c index 1c8384a..d31c143 100644 --- a/src/commands/ls.c +++ b/src/commands/ls.c @@ -166,10 +166,13 @@ static char* get_file_color(struct FileInfo* info) { } static void list_files(struct FileInfo* files, int file_len, struct FileListInfo info, struct Flags* flags, const char* dir_path) { - struct winsize w; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + if (!isatty(1)) { + flags->one_column = true; + } + char* color; const int column_width = info.max_name + 1; const int row_count = w.ws_col / column_width; @@ -371,7 +374,6 @@ COMMAND(ls) { flags.hide_dot = false; flags.one_column = false; flags.recurse = false; - int start = 0; for (int i = 0; i < argc; i++) { if (!prefix("-", argv[i])) break;