Linguist: Shell not recognised

Created on 30 Aug 2016  Â·  11Comments  Â·  Source: github/linguist

Hi,

https://github.com/MirBSD/kwalletcli lists as:

Groff 55.0% C 18.4% C++ 16.6% Makefile 10.0% 

However, the lines-as-counted-by-wc distribute as follows:

  • 167 make
  • 86 text (UTF-8)
  • 380 C
  • 329 C++
  • 665 shell
  • 1094 nroff
  • 2123 SVG

(plus three *.png files I don’t count, as they’re binary)

Add Language

All 11 comments

What's mksh?

John Gardner dixit:

What's mksh?

The successor of pdksh, and an independent Korn shell implementation
(with the blessing of David Korn).

Disclaimer: I am the current developer of mksh.

bye,

//mirabilos

FWIW, I'm quite impressed with mksh interactively. I thought it was much
_much_ more bare bones. But it turns out it beats the living hell out of
ksh93 in that respect. I'd even consider it for my daily use if I hadn't
wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh

Well, the reason the shell-script isn't being recognised as one is because it uses an unfamiliar interpreter directive. Linguist pairs the names of known executables (like bash, ksh, dash, et al) to languages when matching based on hashbangs. Since mksh isn't in the list, it isn't doing any language recognition.

You can manually override that by adding a .gitattributes file with a linguist-language property set. More on that here. Alternatively, adding an Emacs or Vim modeline in the first couple lines of the file will help, too. :-)

John Gardner dixit:

Erh... do you have your language settings set to Latin? :|

About 100 repositories mention mksh. I don't think it would be unreasonable to add it to the list of shell interpreters.

EDIT: That's just in the repository name. This search get 7000 hits.

EDIT: That's just in the repository name. This search get 7000 hits.

@larsbrinkhoff Results of your search don't seem to contain the mksh shebang :/
This search yields only 47 files with mksh shebangs.

John Gardner dixit:

Well, the reason the shell-script isn't being recognised as one is
because it uses an unfamiliar interpreter directive. Linguist pairs
the names of known executables (like bash, ksh, dash, et al) to
languages when matching based on hashbangs. Since mksh isn't in the
list, it isn't doing any language recognition.

mksh was added to Debian’s static code checker in, I don’t know,
2008 or so, so…

Lars Brinkhoff dixit:

About 100 repositories mention mksh. I don't think it would be
unreasonable to add it to the list of shell interpreters.

… yes please!

John Gardner dixit:

John Gardner dixit:

Erh... do you have your language settings set to Latin? :|

What is “language settings”? My Unix system doesn’t have that.
But yes, this is Latin.

Paul Chaignon dixit:

EDIT: That's just in the repository name. This search get 7000 hits.

@larsbrinkhoff Results of your search don't seem to contain the mksh shebang :/
[This search](https://github.com/search?p=1&q=%22usr%2Fbin%2Fenv+mksh%22

“This search” is broken, the standard shebang is “#!/bin/mksh”,
only some (predominantly older) scripts use “#!/usr/bin/env mksh”.

Please make sure both are recognised for scripts.

Some distributions also have “mksh-static” and “lksh” as binaries
in the mksh package, although the former tends to only be used for
some local scripts using a “rescue shell”, and the latter is only
used by “legacy scripts”, i.e. those that require the shell to behave
as older korn or bourne shell variants did, for some things. Although
adding them would not be unreasonable.

If you want, I can do a recherche on which shells a contemporary GNU
system offers (trivial, as I’ve installed most of them, for testing
mksh against their behaviour) and submit a pull request adding them,
in both shebang forms, to your lists, so we have them all at once.

bye,

//mirabilos

„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)

Results of your search don't seem to contain the mksh shebang

@pchaigno No, but that't not what I was trying to find. I just wanted to vaguely gauge the popularity of this shell.

Lars Brinkhoff dixit:

I just wanted to vaguely gauge the popularity of this shell.

Roughly two billion installations, although not as /bin/mksh
but as /system/bin/sh on Android.

So, nothing to get worked up about ;-)

bye,

//mirabilos

Beware of ritual lest you forget the meaning behind it.
yeah but it means if you really care about something, don't
ritualise it, or you will lose it. don't fetishise it, don't
obsess. or you'll forget why you love it in the first place.

/bin/mksh is POSIX-compliant, and is usually symlinked to /bin/sh. Most mksh users use usual #!/bin/sh shebang In order to ensure compatibility with other POSIX-compliant shells, which is why results are skewed.

/bin/dash is in similar situation. Perhaps it makes sense to add less popular shells in a bulk?

PR to add a few more shells: https://github.com/github/linguist/pull/3708

Looks like Linguist now recognises a lot more shell including all those mentioned here, so I'm closing this issue. If there's anything missing or we need further extensions, please open a new issue or submit a PR for those.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

etc0de picture etc0de  Â·  5Comments

philiparvidsson picture philiparvidsson  Â·  4Comments

haskellcamargo picture haskellcamargo  Â·  3Comments

BnSalahFahmi picture BnSalahFahmi  Â·  3Comments

FranklinYu picture FranklinYu  Â·  4Comments