diff options
Diffstat (limited to 'src/commands/ls.c')
-rw-r--r-- | src/commands/ls.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/commands/ls.c b/src/commands/ls.c index fec8cdd..a5c60d2 100644 --- a/src/commands/ls.c +++ b/src/commands/ls.c @@ -55,9 +55,9 @@ static DIR* get_directory(char* path) { DIR* d = opendir(path); if (d == NULL) { if (errno == ENOTDIR) { - printf("\x1b[0m%s is a a file\n", path); + error_s("`%s` is a a file\n", path); } else { - printf("\x1b[0merror: failed to open directory '%s': %s\n", path, strerror(errno)); + error_s("failed to open directory '%s': %s\n", path, strerror(errno)); } } return d; @@ -74,7 +74,7 @@ static bool get_file_info(const char* file_name, struct FileInfo* info) { int save = push_path_buffer(file_name); if (lstat(get_path_buffer(), &s) < 0) { - printf("\x1b[0merror: failed to read file '%s': %s\n", get_path_buffer(), strerror(errno)); + error_s("failed to read file '%s': %s\n", get_path_buffer(), strerror(errno)); pop_path_buffer(save); return false; } @@ -156,14 +156,14 @@ static bool get_file_info(const char* file_name, struct FileInfo* info) { info->usr = getpwuid(s.st_uid); if (info->usr == NULL) { - fprintf(stderr, "error: failed to get user from %s\n", get_path_buffer()); + error_s("failed to get user from `%s`\n", get_path_buffer()); pop_path_buffer(save); return false; } info->grp = getgrgid(s.st_gid); if (info->grp == NULL) { - fprintf(stderr, "error: failed to get user from %s\n", get_path_buffer()); + error_s("failed to get user from `%s`\n", get_path_buffer()); pop_path_buffer(save); return false; } @@ -288,10 +288,6 @@ static void list_files(struct FileInfo* files, int file_len, struct FileListInfo if (!flags.more_info) printf("\n"); } -static bool is_dot_dir(const char* path) { - return streql(path, ".") || streql(path, ".."); -} - static int num_places (int n) { int r = 1; if (n < 0) n = (n == INT_MIN) ? INT_MAX: -n; @@ -465,7 +461,7 @@ static int short_arg(char c, char* next) { flags.more_info = true; break; default: - error("error: unkown option -%c", c); + return ARG_INVALID; } return ARG_UNUSED; } @@ -481,7 +477,7 @@ static int long_arg(char* cur, char* next) { } else if (streql("no", arg) || streql("never", arg)) { flags.colored = NO; } else { - error("error: invalid color options: %s", arg); + error("invalid color options: %s", arg); } } else { return ARG_IGNORE; @@ -496,7 +492,7 @@ COMMAND(ls) { flags.hide_dot = false; flags.one_column = false; flags.recurse = false; - flags.colored = AUTO; + flags.colored = NO; int start = parse_args(argc, argv, help, short_arg, long_arg); |