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

Re: [PATCH v3 0/3] Improve robustness of putty detection

From
Jeff King <peff@peff.net>
Date
Apr 28, 2015, 04:15 UTC
Message-ID
<20150428041521.GB24580@peff.net>
In-Reply-To
<xmqq4mo2zgtz.fsf@gitster.dls.corp.google.com>
On Sun, Apr 26, 2015 at 03:04:56PM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> The test scripts are expected to take either 3 or 4 parameters, and
> the extra parameter when it takes 4 is the comma separated list of
> prerequisites.  "bracketed hostnames are still ssh" does not look
> like prerequisites at all to us humans, and the framework should
> also be able to notice that and barf, I would think.
> 
> Perhaps something like this?

I like it. I wondered if we could even recognize a known set of prereqs (e.g., say "I don't know about the FOO prereq; did you forget to test_lazy_prereq it?"), but I don't think we can. Some of the prereqs are set by arbitrary code, and when they are not set, we don't call a "test_do_not_set_prereq FOO". Enforcing a sane syntax is almost as good, and seems pretty easy to implement.

Show 5 quoted lines
> +test_verify_prereq () {
> +	test -z "$test_prereq" ||
> +	expr >/dev/null "$test_prereq" : '^[A-Z0-9_,!]*$' ||
> +	error "bug in the test script: '$test_prereq' does not look like a prereq"
> +}

The leading "^" is unnecessary in an expr regexp, as such expressions are always left-anchored. And according to POSIX, even undesirable due to hysterical raisins. You do still need the '$' to anchor the end.

I was surprised that the regexp does not match the empty string itself (making the initial "test -z" redundant), but it does not seem to with my version of expr. Weird. I think it is because the exit value is not "did it match" but "is the return value of the expression non-zero", and of course we matched zero characters.

At any rate, we are probably much better off having the initial "test -z" there as an optimization, anyway. "expr" is not usually a built-in, and otherwise we add an extra fork to each test invocation (not something I expect matters under Linux, but I know Windows folks are very sensitive to it).

-Peff
Previous: Torsten BögershausenNext: brian m. carlson
Message 37 of 41 in “[BUG] having 'plink' anywhere in the GIT_SSH environment variables sets putty = true”
  1. Patrick SharpApr 22, 2015
  2. Johannes SchindelinApr 22, 2015
  3. Patrick SharpApr 22, 2015
  4. Jeff KingApr 22, 2015
  5. brian m. carlsonApr 22, 2015
  6. Jeff KingApr 22, 2015
  7. brian m. carlsonApr 22, 2015
  8. Jeff KingApr 22, 2015
  9. brian m. carlsonApr 22, 2015
  10. Jeff KingApr 22, 2015
  11. 1/2 connect: simplify SSH connection code pathbrian m. carlson, Apr 23, 2015
  12. 2/2 connect: improve check for plink to reduce false positivesbrian m. carlson, Apr 23, 2015
  13. Johannes SchindelinApr 23, 2015
  14. Jeff KingApr 23, 2015
  15. brian m. carlsonApr 23, 2015
  16. Johannes SchindelinApr 24, 2015
  17. 1/2 connect: simplify SSH connection code pathbrian m. carlson, Apr 24, 2015
  18. 2/2 connect: improve check for plink to reduce false positivesbrian m. carlson, Apr 24, 2015
  19. Pete HarlanApr 24, 2015
  20. brian m. carlsonApr 24, 2015
  21. Torsten BögershausenApr 25, 2015
  22. brian m. carlsonApr 26, 2015
  23. 0/3 Improve robustness of putty detectionbrian m. carlson, Apr 26, 2015
  24. 1/3 connect: simplify SSH connection code pathbrian m. carlson, Apr 26, 2015
  25. 2/3 t5601: fix quotation error leading to skipped testsbrian m. carlson, Apr 26, 2015
  26. 3/3 connect: improve check for plink to reduce false positivesbrian m. carlson, Apr 26, 2015
  27. Johannes SchindelinApr 27, 2015
  28. Jeff KingApr 28, 2015
  29. Jeff KingJun 26, 2015
  30. Junio C HamanoJun 26, 2015
  31. Jeff KingJun 26, 2015
  32. Johannes SchindelinJun 26, 2015
  33. Jeff KingJun 26, 2015
  34. brian m. carlsonJun 26, 2015
  35. Junio C HamanoApr 26, 2015
  36. Torsten BögershausenApr 27, 2015
  37. Jeff KingApr 28, 2015
  38. brian m. carlsonApr 29, 2015
  39. Johannes SchindelinApr 24, 2015
  40. Torsten BögershausenApr 23, 2015
  41. Patrick SharpApr 23, 2015

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.