git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] remove #!interpreter line from shell libraries

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 12, 2012, 19:17 UTC
Message-ID
<20120312191703.GB21817@burratino>
In-Reply-To
<4F5E4618.10102@xiplink.com>
Hi,
Marc Branchaud wrote:
> On 12-03-09 02:58 AM, Clemens Buchacher wrote:
>> On Thu, Mar 08, 2012 at 06:14:04AM -0600, Jonathan Nieder wrote:
>>> +++ b/git-mergetool--lib.sh
>>> @@ -1,5 +1,4 @@
>>> -#!/bin/sh
[...]
>> This breaks vim's filetype detection. It can still guess the file type
>> from the .sh extension, but we strip the extension during the build.
>> Although one should typically work with the source files, in the past I
>> did have a look at the installed files on a few occasions.

It seems moot until someone has had time to deal with the --valgrind fallout Jeff mentioned. Here are my thoughts anyway.

vim's filetype detection has been broken for me in other ways, too: when it sees "#!/bin/sh", by default it assumes that this is a script intended for Solaris's lowest-common-denominator Bourne shell and decides to annoyingly flag POSIXisms in red. So I end up needing to override vim's default heuristics already.

By the way, my mild dislike for the #! line in shell libraries is actually rooted in functionality, in a way. Though it would never happen in git, I have had too many unhappy experiences of shell libraries with #!/bin/bash at the top that were used in #!/bin/sh scripts and broke completely. So that is where the bad association comes from.

Steering people towards git-sh-setup.sh when they try to edit git-sh-setup is just a happy side-effect.

[...]
> How about a modeline?  I think the following would work for both emacs and
> vi(m?) (I'm not a vi user, so I might have it wrong):
>
> 	# -*-mode:shell-script-*-   vi: filetype=sh

A modeline becomes a distraction as people work to get the settings perfect with respect to line length, indentation style, and changes in supported editors, and to get them applied consistently as new files are added.

So from a maintainability point of view, it seems wasteful --- better to ask people to configure their editor to recognize .sh files, #!/bin/sh, and files starting with "# " or containing "is a shell library" on the first line once and be done with it.

Of course I can easily be convinced otherwise.

Thanks for some useful observations and for catching the huge holes in the change description.

Sincerely, Jonathan

Previous: Marc BranchaudNext: Clemens Buchacher
Message 5 of 8 in “remove #!interpreter line from shell libraries”
  1. remove #!interpreter line from shell librariesJonathan Nieder, Mar 8, 2012
  2. Jeff KingMar 8, 2012
  3. Clemens BuchacherMar 9, 2012
  4. Marc BranchaudMar 12, 2012
  5. Jonathan NiederMar 12, 2012
  6. Clemens BuchacherMar 13, 2012
  7. Junio C HamanoMar 12, 2012
  8. Clemens BuchacherMar 12, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.