Why does linux recognise a C# .cs file as a C++ source file?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I used the file command on a c# source file, and linux thought it was a c++ file. What is the reason for this?
c++ file-command c#
add a comment |Â
up vote
2
down vote
favorite
I used the file command on a c# source file, and linux thought it was a c++ file. What is the reason for this?
c++ file-command c#
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I used the file command on a c# source file, and linux thought it was a c++ file. What is the reason for this?
c++ file-command c#
I used the file command on a c# source file, and linux thought it was a c++ file. What is the reason for this?
c++ file-command c#
edited Jun 7 at 2:52
muru
33.2k576140
33.2k576140
asked Jun 7 at 2:34
J. Czekaj
132
132
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Take a look at the man page for the file
command:
$ man file
...
file tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order: filesystem
tests, magic tests, and language tests. The first test that succeeds
causes the file type to be printed.
It's the third test (language tests) that file
performs that's categorizing this file as a C++ file.
Once file has determined the character set used in a text-type file,
it will attempt to determine in what language the file is written.
The language tests look for particular strings (cf. #include
) that can appear anywhere in the first few blocks of a file. For example, the keyword .br indicates that the file is most likely a
troff(1) input file, just as the keyword struct indicates a C program.
These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some
miscellany (such as tar(1) archives).
C# files most closely match to C++ files and so file
"guesses" that the .cs file is a C++ file.
Example
$ more blah.cs
// A Hello World! program in C#.
using System;
namespace HelloWorld
class Hello
static void Main()
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Checking with file
:
$ file blah.cs
blah.cs: ASCII C++ program text
Add to this: the original file command looks only at file contents, not the filename. So it doesnâÂÂt recognize that a .cs file contains syntax that looks vaguely like C++ but which is actually a different language C#. // Many folks extend file to look at the filename as well, but that produces other problems.
â Krazy Glew
Jun 7 at 4:23
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Take a look at the man page for the file
command:
$ man file
...
file tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order: filesystem
tests, magic tests, and language tests. The first test that succeeds
causes the file type to be printed.
It's the third test (language tests) that file
performs that's categorizing this file as a C++ file.
Once file has determined the character set used in a text-type file,
it will attempt to determine in what language the file is written.
The language tests look for particular strings (cf. #include
) that can appear anywhere in the first few blocks of a file. For example, the keyword .br indicates that the file is most likely a
troff(1) input file, just as the keyword struct indicates a C program.
These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some
miscellany (such as tar(1) archives).
C# files most closely match to C++ files and so file
"guesses" that the .cs file is a C++ file.
Example
$ more blah.cs
// A Hello World! program in C#.
using System;
namespace HelloWorld
class Hello
static void Main()
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Checking with file
:
$ file blah.cs
blah.cs: ASCII C++ program text
Add to this: the original file command looks only at file contents, not the filename. So it doesnâÂÂt recognize that a .cs file contains syntax that looks vaguely like C++ but which is actually a different language C#. // Many folks extend file to look at the filename as well, but that produces other problems.
â Krazy Glew
Jun 7 at 4:23
add a comment |Â
up vote
2
down vote
accepted
Take a look at the man page for the file
command:
$ man file
...
file tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order: filesystem
tests, magic tests, and language tests. The first test that succeeds
causes the file type to be printed.
It's the third test (language tests) that file
performs that's categorizing this file as a C++ file.
Once file has determined the character set used in a text-type file,
it will attempt to determine in what language the file is written.
The language tests look for particular strings (cf. #include
) that can appear anywhere in the first few blocks of a file. For example, the keyword .br indicates that the file is most likely a
troff(1) input file, just as the keyword struct indicates a C program.
These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some
miscellany (such as tar(1) archives).
C# files most closely match to C++ files and so file
"guesses" that the .cs file is a C++ file.
Example
$ more blah.cs
// A Hello World! program in C#.
using System;
namespace HelloWorld
class Hello
static void Main()
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Checking with file
:
$ file blah.cs
blah.cs: ASCII C++ program text
Add to this: the original file command looks only at file contents, not the filename. So it doesnâÂÂt recognize that a .cs file contains syntax that looks vaguely like C++ but which is actually a different language C#. // Many folks extend file to look at the filename as well, but that produces other problems.
â Krazy Glew
Jun 7 at 4:23
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Take a look at the man page for the file
command:
$ man file
...
file tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order: filesystem
tests, magic tests, and language tests. The first test that succeeds
causes the file type to be printed.
It's the third test (language tests) that file
performs that's categorizing this file as a C++ file.
Once file has determined the character set used in a text-type file,
it will attempt to determine in what language the file is written.
The language tests look for particular strings (cf. #include
) that can appear anywhere in the first few blocks of a file. For example, the keyword .br indicates that the file is most likely a
troff(1) input file, just as the keyword struct indicates a C program.
These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some
miscellany (such as tar(1) archives).
C# files most closely match to C++ files and so file
"guesses" that the .cs file is a C++ file.
Example
$ more blah.cs
// A Hello World! program in C#.
using System;
namespace HelloWorld
class Hello
static void Main()
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Checking with file
:
$ file blah.cs
blah.cs: ASCII C++ program text
Take a look at the man page for the file
command:
$ man file
...
file tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order: filesystem
tests, magic tests, and language tests. The first test that succeeds
causes the file type to be printed.
It's the third test (language tests) that file
performs that's categorizing this file as a C++ file.
Once file has determined the character set used in a text-type file,
it will attempt to determine in what language the file is written.
The language tests look for particular strings (cf. #include
) that can appear anywhere in the first few blocks of a file. For example, the keyword .br indicates that the file is most likely a
troff(1) input file, just as the keyword struct indicates a C program.
These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some
miscellany (such as tar(1) archives).
C# files most closely match to C++ files and so file
"guesses" that the .cs file is a C++ file.
Example
$ more blah.cs
// A Hello World! program in C#.
using System;
namespace HelloWorld
class Hello
static void Main()
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Checking with file
:
$ file blah.cs
blah.cs: ASCII C++ program text
answered Jun 7 at 3:01
slmâ¦
234k65480653
234k65480653
Add to this: the original file command looks only at file contents, not the filename. So it doesnâÂÂt recognize that a .cs file contains syntax that looks vaguely like C++ but which is actually a different language C#. // Many folks extend file to look at the filename as well, but that produces other problems.
â Krazy Glew
Jun 7 at 4:23
add a comment |Â
Add to this: the original file command looks only at file contents, not the filename. So it doesnâÂÂt recognize that a .cs file contains syntax that looks vaguely like C++ but which is actually a different language C#. // Many folks extend file to look at the filename as well, but that produces other problems.
â Krazy Glew
Jun 7 at 4:23
Add to this: the original file command looks only at file contents, not the filename. So it doesnâÂÂt recognize that a .cs file contains syntax that looks vaguely like C++ but which is actually a different language C#. // Many folks extend file to look at the filename as well, but that produces other problems.
â Krazy Glew
Jun 7 at 4:23
Add to this: the original file command looks only at file contents, not the filename. So it doesnâÂÂt recognize that a .cs file contains syntax that looks vaguely like C++ but which is actually a different language C#. // Many folks extend file to look at the filename as well, but that produces other problems.
â Krazy Glew
Jun 7 at 4:23
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448319%2fwhy-does-linux-recognise-a-c-cs-file-as-a-c-source-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password