Skip to content

Commit

Permalink
Userland: Return 1 when help text is shown for insufficient args
Browse files Browse the repository at this point in the history
ArgsParser also does this, but we don't use that (yet) in a couple of
places. Fix the behaviour manually for consistency.
  • Loading branch information
linusg committed Jun 1, 2021
1 parent f5c35fc commit 2a94046
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Userland/Utilities/chown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(int argc, char** argv)

if (argc < 3) {
warnln("usage: chown <uid[:gid]> <path>");
return 0;
return 1;
}

uid_t new_uid = -1;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Utilities/fgrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char** argv)
{
if (argc < 2) {
warnln("usage: fgrep <str>");
return 0;
return 1;
}
for (;;) {
char buf[4096];
Expand Down
2 changes: 1 addition & 1 deletion Userland/Utilities/flock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char** argv)
{
if (argc < 3) {
warnln("usage: flock <path> <command...>");
return 0;
return 1;
}

pid_t child_pid;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Utilities/gron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char** argv)
if (argc != 2 || !strcmp(argv[1], "--help")) {
warnln("usage: gron <file>");
warnln("Print each value in a JSON file with its fully expanded key.");
return 0;
return argc != 2 ? 1 : 0;
}
auto file = Core::File::construct(argv[1]);
if (!file->open(Core::OpenMode::ReadOnly)) {
Expand Down
2 changes: 1 addition & 1 deletion Userland/Utilities/mknod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ constexpr unsigned encoded_device(unsigned major, unsigned minor)
static int usage()
{
warnln("usage: mknod <name> <c|b|p> [<major> <minor>]");
return 0;
return 1;
}

int main(int argc, char** argv)
Expand Down

0 comments on commit 2a94046

Please sign in to comment.