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

Re: [PATCH] git-web--browser: avoid errors in terminal when running Firefox on Windows

From
Jeff King <peff@peff.net>
Date
Nov 11, 2011, 18:35 UTC
Message-ID
<20111111183555.GC16055@sigill.intra.peff.net>
In-Reply-To
<1321028283-17307-1-git-send-email-Alex.Crezoff@gmail.com>
On Fri, Nov 11, 2011 at 08:18:03PM +0400, Alexey Shumkin wrote:
Show 5 quoted lines
> Firefox on Windows by default is placed in "C:\Program Files\Mozilla Firefox"
> folder, i.e. its path contains spaces. Before running this browser "git-web--browse"
> tests version of Firefox to decide whether to use "-new-tab" option or not.
> 
> Quote browser path to avoid error during this test.
Thanks. I even noticed this bug early on in the previous discussion:
  http://article.gmane.org/gmane.comp.version-control.git/181600

but forgot about it by the time the final patch rolled around. Your fix looks correct, but:

Show 7 quoted lines
>  test_expect_success \
> +	'Firefox below v2.0 paths are properly quoted' '
> +	echo fake: http://example.com/foo >expect &&
> +	cat >"fake browser" <<-\EOF &&
> +	#!/bin/sh
> +
> +	if [ "$1" == "-version" ]; then
Using "==" is a bashism. Just use "=".

Also, a style nit, but we usually spell this "test" and not "[". I admit I don't care much, though.

Show 10 quoted lines
> +		# Firefox (in contrast to w3m) is run in background (with &)
> +		# so redirect output to "actual"
> +		echo fake: "$@" > actual
> +	fi
> +	EOF
> +	chmod +x "fake browser" &&
> +	git config browser.firefox.path "`pwd`/fake browser" &&
> +	git web--browse --browser=firefox \
> +		http://example.com/foo &&
> +	test_cmp expect actual

Hmm. So we are running the fake browser in the background, but then check that it has written something as soon as web--browse exits. Isn't that a race condition? I.e., we could run "test_cmp" before the browser has actually written anything?

I'm not sure there's a good way to do it. You would need either to wait some pre-determined "it could not possibly take it longer than N seconds to run" sleep, or we need some kind of synchronization point. We can't wait call "wait" on the child PID (if we even have it, because it's not our child).

-Peff
Previous: Jeff KingNext: Alexey Shumkin
Message 3 of 12 in “[PATCHv3] git-web--browse: avoid the use of eval”
  1. Chris PackhamOct 2, 2011
  2. Jeff KingOct 3, 2011
  3. Jeff KingNov 11, 2011
  4. Alexey ShumkinNov 11, 2011
  5. Jeff KingNov 11, 2011
  6. git-web--browser: avoid errors in terminal when running Firefox on WindowsAlexey Shumkin, Jan 25, 2013
  7. Junio C HamanoJan 25, 2013
  8. 0/2 git-web--browser: avoid errors in terminal when runningAlexey Shumkin, Jan 26, 2013
  9. 1/2 t9901-git-web--browse.sh: Use "write_script" helperAlexey Shumkin, Jan 26, 2013
  10. 2/2 git-web--browser: avoid errors in terminal when running Firefox on WindowsAlexey Shumkin, Jan 26, 2013
  11. Jeff KingJan 25, 2013
  12. Shumkin AlexeyJan 25, 2013

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.