aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/file.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-08-31 03:59:25 +0000
committerrsc <devnull@localhost>2005-08-31 03:59:25 +0000
commitadee16764bbedce94c80f2665d1c0c1dd40900ca (patch)
treeb7884e129875309ebba0586ed76c0e60bcc10b8a /src/cmd/file.c
parentdb3f85b9fed0c67bbc6afb56798aabcf04e35673 (diff)
downloadplan9port-adee16764bbedce94c80f2665d1c0c1dd40900ca.tar.gz
plan9port-adee16764bbedce94c80f2665d1c0c1dd40900ca.tar.bz2
plan9port-adee16764bbedce94c80f2665d1c0c1dd40900ca.zip
Better handling of executables.
Diffstat (limited to 'src/cmd/file.c')
-rw-r--r--src/cmd/file.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cmd/file.c b/src/cmd/file.c
index fb3d2a34..ce739d05 100644
--- a/src/cmd/file.c
+++ b/src/cmd/file.c
@@ -637,8 +637,6 @@ struct FILE_STRING
"!<arch>\n__.SYMDEF", "archive random library", 16, "application/octet-stream",
"!<arch>\n", "archive", 8, "application/octet-stream",
"070707", "cpio archive - ascii header", 6, "application/octet-stream",
- "#!/bin/rc", "rc executable file", 9, "text/plain",
- "#!/bin/sh", "sh executable file", 9, "text/plain",
"%!", "postscript", 2, "application/postscript",
"\004%!", "postscript", 3, "application/postscript",
"x T post", "troff output for post", 8, "application/troff",
@@ -668,7 +666,7 @@ struct FILE_STRING
int
istring(void)
{
- int i;
+ int i, j;
struct FILE_STRING *p;
for(p = file_string; p->key; p++) {
@@ -690,6 +688,17 @@ istring(void)
print("%.*s picture\n", utfnlen((char*)buf+5, i-5), (char*)buf+5);
return 1;
}
+ if(buf[0]=='#' && buf[1]=='!'){
+ i=2;
+ for(j=2; j < nbuf && buf[j] != ' ' && buf[j] != '\n' && buf[j] != '\r'; j++)
+ if(buf[j] == '/')
+ i = j+1;
+ if(mime)
+ print(PLAIN);
+ else
+ print("%.*s executable file script\n", utfnlen((char*)buf+i, j-i), (char*)buf+i);
+ return 1;
+ }
return 0;
}
@@ -1245,7 +1254,7 @@ iself(void)
};
- if (memcmp(buf, "\0177ELF", 4) == 0){
+ if (memcmp(buf, "\177ELF", 4) == 0){
/* gcc misparses \x7FELF as \x7FE L F */
if (!mime){
int n = (buf[19] << 8) | buf[18];