From a9ab166c568d312122ae414968b831ebd4f57711 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <enh@google.com>
Date: Fri, 10 Nov 2023 18:40:01 +0000
Subject: [PATCH] file: recognize wasm binary modules.

---
 toys/posix/file.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/toys/posix/file.c b/toys/posix/file.c
index cada80e1..1fdbefde 100644
--- a/toys/posix/file.c
+++ b/toys/posix/file.c
@@ -445,6 +445,10 @@ static void do_regular_file(int fd, char *name)
   } else if (len>4 && !smemcmp(s, "ABX", 3)) {
     xprintf("Android Binary XML v%d\n", s[3]);
 
+    // https://webassembly.github.io/spec/core/binary/modules.html#binary-module
+  } else if (len>8 && !smemcmp(s, "\0asm", 4)) {
+    xprintf("wasm binary module version %d\n", (int)peek_le(s+4, 4));
+
     // Text files, including shell scripts.
   } else {
     char *what = 0;
-- 
2.42.0.869.gea05f2083d-goog

