diff options
author | Jakob Kaivo <jkk@ung.org> | 2018-10-13 12:10:50 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2018-10-13 12:10:50 -0400 |
commit | b5756941692e2452fc0ffb7f8e9e51c95d2e9d6c (patch) | |
tree | d35ac379dcf1fcccae76645cd764d85396c95d22 | |
parent | c96a1c7f9cea82470a99691d2832c6599c8eff10 (diff) |
fix comma and row output
-rwxr-xr-x | color-ls.awk | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/color-ls.awk b/color-ls.awk index e19c77a..056bc9d 100755 --- a/color-ls.awk +++ b/color-ls.awk @@ -30,7 +30,7 @@ BEGIN { } } -function columns_down() { +function columns_output() { widest++; column = 0; columns = ENVIRON["COLUMNS"]; @@ -56,7 +56,7 @@ function columns_down() { } } -function columns_across() { +function row_output() { widest++; column = 0; columns = ENVIRON["COLUMNS"]; @@ -65,7 +65,7 @@ function columns_across() { } for (i = 1; i <= NR; i++) { - printf("%-*s", widest, all[i]); + printf("%-*s ", widest, file[i]); column += widest; if (column > columns) { printf("\n"); @@ -86,8 +86,9 @@ function long_output() { function comma_output() { for (i = 1; i <= NR; i++) { - printf("%s%s", i == 1 ? "" : ", ", $0 ); + printf("%s%s", i == 1 ? "" : ", ", file[i]); } + printf("\n"); } { color=39; } @@ -109,12 +110,12 @@ function comma_output() { } END { - if (output == "-x") { - columns_across(); - } else if (output == "-C") { - columns_down(); - } else if (output == "-m") { - commat_output(); + if (output == "x") { + row_output(); + } else if (output == "C") { + columns_output(); + } else if (output == "m") { + comma_output(); } else { long_output(); } |