changeset 11853:97b02eed7f57 draft

<b_jonas> fetch bin/whatis https://hack.esolangs.org/get/bin/whatis
author HackEso <hackeso@esolangs.org>
date Tue, 16 Jul 2019 16:54:11 +0000
parents 87b3b7dcb024
children cc933fc31298
files bin/whatis
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bin/whatis	Tue Jul 16 16:41:51 2019 +0000
+++ b/bin/whatis	Tue Jul 16 16:54:11 2019 +0000
@@ -4,16 +4,24 @@
     print("whatis what?")
     sys.exit(1)
 else:
+    argorg = []
     argfoldv = []
+    foundv = []
     for arg in sys.argv[1:]:
+        argorg.append(arg)
         argfoldv.append(arg.casefold())
+        foundv.append(False)
     with open("/hackenv/share/whatis", errors="surrogateescape") as whatisdb:
         for line in whatisdb:
             parts = re.match(r"([^()]+)\(([0-9A-Z_a-z]+)\)", line)
             if parts:
                 match = False
-                for argfold in argfoldv:
-                    match = match or argfold == parts.group(1).casefold()
+                for argind, argfold in enumerate(argfoldv):
+                    if argfold == parts.group(1).casefold():
+                        match = True
+                        foundv[argind] = True
                 if match:
-                    sys.stdout.write(line)
-
+                    print(line, end="")
+        for arg, found in zip(foundv):
+            if not found:
+                print(arg + ": nothing appropriate.")