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

Re: [RFC] Add basic syntax check on shell scripts

From
Jeff King <peff@peff.net>
Date
Dec 5, 2012, 07:54 UTC
Message-ID
<20121205075401.GB5776@sigill.intra.peff.net>
In-Reply-To
<20121205073055.GA5776@sigill.intra.peff.net>
On Wed, Dec 05, 2012 at 02:30:56AM -0500, Jeff King wrote:
Show 5 quoted lines
> Anyway, I do think a "shell portability lint" would be a great addition
> to "test-lint", but I am slightly skeptical that it will be easy to
> write a good one that does not have false positives. Still, there may be
> some low-hanging fruit. I have not looked carefully at Torsten's patch
> yet.

Hrm. I had the impression initially that Torsten's patch was about testing the test scripts themselves. But it is really about testing the installed shell scripts. In that sense, test-lint is not the right place.

You would want a "check shell script portability" script, and you would probably want to run it:

  - on the regular built scripts; possibly during build time (I have done
    this before with "perl -c" for perl scripts and it is reasonably
    successful). Or in a test script, as added in his patch (though I
    note it does not seem to pass as posted, getting confused by trying
    to grep "git-gui").
  - on the test scripts themselves via test-lint

I think as long as such a script erred on the side of false negatives, it would be OK (because false positives are a giant headache, and ultimately the real test is people exercising the code itself on their shells; this is just an early check to help contributors who do not have such shells).

-Peff
PS Debian developers use a checkbashisms script to find some portability
   problems. It might be worth looking at, though I notice it generates
   a lot of bogus "unterminated string" results for our t/t*.sh scripts.
Previous: Jeff KingNext: Junio C Hamano
Message 9 of 11 in “[RFC] Add basic syntax check on shell scripts”
  1. Torsten BögershausenDec 2, 2012
  2. Stefano LattariniDec 2, 2012
  3. Junio C HamanoDec 3, 2012
  4. Nguyen Thai Ngoc DuyDec 4, 2012
  5. Junio C HamanoDec 4, 2012
  6. Nguyen Thai Ngoc DuyDec 5, 2012
  7. Junio C HamanoDec 5, 2012
  8. Jeff KingDec 5, 2012
  9. Jeff KingDec 5, 2012
  10. Junio C HamanoDec 5, 2012
  11. Sebastian SchuberthDec 5, 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.