mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:47:45 +00:00
ls: Add the -g
option to omit owner information in long format
This commit is contained in:
parent
d618ef58fb
commit
cb1851f3cc
2 changed files with 11 additions and 6 deletions
|
@ -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)
|
* `-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`
|
* `-n`, `--numeric-uid-gid`: In long format, display numeric UID/GID. Implies `-l`
|
||||||
* `-o`: In long format, do not show group information. 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
|
* `-h`, `--human-readable`: Print human-readable sizes
|
||||||
* `--si`: Print human-readable sizes in SI units
|
* `--si`: Print human-readable sizes in SI units
|
||||||
* `-K`, `--no-hyperlinks`: Disable hyperlinks
|
* `-K`, `--no-hyperlinks`: Disable hyperlinks
|
||||||
|
|
|
@ -76,6 +76,7 @@ static bool flag_show_inode = false;
|
||||||
static bool flag_show_raw_inode = false;
|
static bool flag_show_raw_inode = false;
|
||||||
static bool flag_print_numeric = false;
|
static bool flag_print_numeric = false;
|
||||||
static bool flag_hide_group = false;
|
static bool flag_hide_group = false;
|
||||||
|
static bool flag_hide_owner = false;
|
||||||
static bool flag_human_readable = false;
|
static bool flag_human_readable = false;
|
||||||
static bool flag_human_readable_si = false;
|
static bool flag_human_readable_si = false;
|
||||||
static FieldToSortBy flag_sort_by { FieldToSortBy::Name };
|
static FieldToSortBy flag_sort_by { FieldToSortBy::Name };
|
||||||
|
@ -133,6 +134,7 @@ ErrorOr<int> 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_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_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_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, "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_human_readable_si, "Print human-readable sizes in SI units", "si", 0);
|
||||||
args_parser.add_option(flag_disable_hyperlinks, "Disable hyperlinks", "no-hyperlinks", 'K');
|
args_parser.add_option(flag_disable_hyperlinks, "Disable hyperlinks", "no-hyperlinks", 'K');
|
||||||
|
@ -141,7 +143,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
args_parser.add_positional_argument(paths, "Directory to list", "path", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(paths, "Directory to list", "path", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
if (flag_print_numeric || flag_hide_group)
|
if (flag_print_numeric || flag_hide_group || flag_hide_owner)
|
||||||
flag_long = true;
|
flag_long = true;
|
||||||
|
|
||||||
if (flag_show_almost_all_dotfiles)
|
if (flag_show_almost_all_dotfiles)
|
||||||
|
@ -368,11 +370,13 @@ static bool print_filesystem_object(DeprecatedString const& path, DeprecatedStri
|
||||||
|
|
||||||
printf(" %3lu", st.st_nlink);
|
printf(" %3lu", st.st_nlink);
|
||||||
|
|
||||||
auto username = users.get(st.st_uid);
|
if (!flag_hide_owner) {
|
||||||
if (!flag_print_numeric && username.has_value()) {
|
auto username = users.get(st.st_uid);
|
||||||
printf(" %7s", username.value().characters());
|
if (!flag_print_numeric && username.has_value()) {
|
||||||
} else {
|
printf(" %7s", username.value().characters());
|
||||||
printf(" %7u", st.st_uid);
|
} else {
|
||||||
|
printf(" %7u", st.st_uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flag_hide_group) {
|
if (!flag_hide_group) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue