Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/common add more argument checking



details:   https://anonhg.NetBSD.org/src/rev/c185a087a7b7
branches:  trunk
changeset: 521865:c185a087a7b7
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Feb 07 11:35:56 2002 +0000

description:
add more argument checking

diffstat:

 distrib/common/makedev2spec.awk |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (63 lines):

diff -r a5b568405448 -r c185a087a7b7 distrib/common/makedev2spec.awk
--- a/distrib/common/makedev2spec.awk   Thu Feb 07 09:43:54 2002 +0000
+++ b/distrib/common/makedev2spec.awk   Thu Feb 07 11:35:56 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: makedev2spec.awk,v 1.1 2002/02/06 16:08:16 lukem Exp $
+#      $NetBSD: makedev2spec.awk,v 1.2 2002/02/07 11:35:56 lukem Exp $
 #
 # Copyright (c) 2002 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -61,6 +61,8 @@
 
 $1 == "mkdir" \
 {
+       if (NF != 2)
+               err("Usage: mkdir dir");
        type[$2] = "type=dir";
        next;
 }
@@ -79,6 +81,8 @@
 
 $1 == "rm" \
 {
+       if (NF < 2)
+               err("Usage: rm [-f] file [...]");
        for (i = 2; i <= NF; i++) {
                if ($i == "-f")
                        continue;
@@ -98,6 +102,8 @@
 # XXX: doesn't change symlinks - need to fix
 $1 == "chgrp" \
 {
+       if (NF < 3)
+               err("Usage: chgrp group file [...]");
        for (i = 3; i <= NF; i++) {
                n = split(glob($i), globs, " ");
                for (j = 1; j <= n; j++) {
@@ -110,6 +116,8 @@
 # XXX: doesn't change symlinks - need to fix
 $1 == "chmod" \
 {
+       if (NF < 3)
+               err("Usage: chmod mode file [...]");
        for (i = 3; i <= NF; i++) {
                n = split(glob($i), globs, " ");
                for (j = 1; j <= n; j++) {
@@ -122,6 +130,8 @@
 # XXX: doesn't change symlinks - need to fix
 $1 == "chown" \
 {
+       if (NF < 3)
+               err("Usage: chown user[:group] file [...]");
        user = $2;
        if ((n = match(user, /[\.:]/)) > 0) {
                group = substr(user, n + 1);
@@ -141,7 +151,7 @@
 }
 
 {
-       err("Unknown keyword " $1);
+       err("Unknown keyword '" $1 "'");
 }
 
 



Home | Main Index | Thread Index | Old Index