blob: 7ac6e67464103e9d1b3ca2712d73ebd4ddb59da7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/usr/bin/lua
magic = require("magic")
m = magic.open()
assert(m:load())
print(m:errno())
-- test magic.descriptor() from stdin
if arg[1] == "--stdin" then
-- stdin = 0
m:setflags(magic.MIME_ENCODING)
print(m:descriptor(0))
os.exit(0)
else
os.execute("lua test.lua --stdin < Makefile")
end
print(m:file("Makefile"))
m:setflags(magic.MIME_TYPE)
print(m:error())
print(m:file("Makefile"))
m:setflags(magic.NONE)
print(m:buffer("#!/bin/bash\n"))
|