diff --git a/Base/usr/share/man/man1/ls.md b/Base/usr/share/man/man1/ls.md index 72e3556c14..e2873d2d28 100644 --- a/Base/usr/share/man/man1/ls.md +++ b/Base/usr/share/man/man1/ls.md @@ -32,6 +32,7 @@ If no *path* argument is provided the current working directory is used. * `-I`, `--raw-inode`: Show raw inode ids if possible (see Notes to understand when this will not work) * `-n`, `--numeric-uid-gid`: In long format, display numeric UID/GID. Implies `-l` * `-o`: In long format, do not show group information. Implies `-l` +* `-g`: In long format, do not show owner information. Implies `-l` * `-h`, `--human-readable`: Print human-readable sizes * `--si`: Print human-readable sizes in SI units * `-K`, `--no-hyperlinks`: Disable hyperlinks diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index cb29ebba74..505b2b2187 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -76,6 +76,7 @@ static bool flag_show_inode = false; static bool flag_show_raw_inode = false; static bool flag_print_numeric = false; static bool flag_hide_group = false; +static bool flag_hide_owner = false; static bool flag_human_readable = false; static bool flag_human_readable_si = false; static FieldToSortBy flag_sort_by { FieldToSortBy::Name }; @@ -133,6 +134,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(flag_show_raw_inode, "Show raw inode ids if possible", "raw-inode", 'I'); args_parser.add_option(flag_print_numeric, "In long format, display numeric UID/GID. Implies '-l'", "numeric-uid-gid", 'n'); args_parser.add_option(flag_hide_group, "In long format, do not show group information. Implies '-l'", nullptr, 'o'); + args_parser.add_option(flag_hide_owner, "In long format, do not show owner information. Implies '-l'", nullptr, 'g'); args_parser.add_option(flag_human_readable, "Print human-readable sizes", "human-readable", 'h'); args_parser.add_option(flag_human_readable_si, "Print human-readable sizes in SI units", "si", 0); args_parser.add_option(flag_disable_hyperlinks, "Disable hyperlinks", "no-hyperlinks", 'K'); @@ -141,7 +143,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(paths, "Directory to list", "path", Core::ArgsParser::Required::No); args_parser.parse(arguments); - if (flag_print_numeric || flag_hide_group) + if (flag_print_numeric || flag_hide_group || flag_hide_owner) flag_long = true; if (flag_show_almost_all_dotfiles) @@ -368,11 +370,13 @@ static bool print_filesystem_object(DeprecatedString const& path, DeprecatedStri printf(" %3lu", st.st_nlink); - auto username = users.get(st.st_uid); - if (!flag_print_numeric && username.has_value()) { - printf(" %7s", username.value().characters()); - } else { - printf(" %7u", st.st_uid); + if (!flag_hide_owner) { + auto username = users.get(st.st_uid); + if (!flag_print_numeric && username.has_value()) { + printf(" %7s", username.value().characters()); + } else { + printf(" %7u", st.st_uid); + } } if (!flag_hide_group) {