diff options
author | Roy Marples <roy@marples.name> | 2007-09-19 16:54:23 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-09-19 16:54:23 +0000 |
commit | 40a1beabe0e1e913a0d58b6a8fd3c6deb0a971fc (patch) | |
tree | 0808d51ef7c25665b09fb468185e4b0e1c1b4acc /src | |
parent | b6aa1c857c9cf4c2d54681875761fa5107433771 (diff) |
Move the error messages to the option parsing
Diffstat (limited to 'src')
-rw-r--r-- | src/checkown.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/checkown.c b/src/checkown.c index 5326321a..b4b22a77 100644 --- a/src/checkown.c +++ b/src/checkown.c @@ -91,27 +91,20 @@ static struct passwd *get_user (char **name) else pw = getpwuid (tid); - if (! pw) - eerrorx ("%s: user `%s' not found", applet, token); + if (pw) + *name = p; - *name = p; return (pw); } static struct group *get_group (const char *name) { - struct group *gr; int tid; if (sscanf (name, "%d", &tid) != 1) - gr = getgrnam (name); + return (getgrnam (name)); else - gr = getgrgid (tid); - - if (! gr) - eerrorx ("%s: group `%s' not found", applet, name); - - return (gr); + return (getgrgid (tid)); } #include "_usage.h" @@ -149,13 +142,15 @@ int checkown (int argc, char **argv) break; case 'u': p = optarg; - pw = get_user (&p); + if (! (pw = get_user (&p))) + eerrorx ("%s: user `%s' not found", applet, optarg); if (p && *p) optarg = p; else break; case 'g': - gr = get_group (optarg); + if (! (gr = get_group (optarg))) + eerrorx ("%s: group `%s' not found", applet, optarg); break; case_RC_COMMON_GETOPT |