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

Re: [PATCH 4/4] t6000lib: workaround a possible dash bug

From
HXHerbert Xu <herbert@gondor.apana.org.au>
Date
Sep 26, 2007, 08:41 UTC
Message-ID
<20070926084144.GA11582@gondor.apana.org.au>
In-Reply-To
<20070921204511.GA10079@muzzle>
On Fri, Sep 21, 2007 at 01:45:11PM -0700, Eric Wong wrote:
Show 5 quoted lines
>
> I tried to reproduce it on a quick script using shell functions,
> multiple arguments, spaces in the $a variable.., but haven't
> been successful.  However, reverting the below patch still
> causes errors in the latest git test suite.

Ah I see, it's a function. Unfortunately POSIX requires shell functions to have the variable assignment properties of special built-ins. So

	X=value func
has the same properties as
	X=value :

In other words, the value assigned to X (and any subsequent values assigned within the function) persists after the call. Also, the variable X is not exported unless it's already been exported.

This is pretty lame but it's how the original Korn shell did things and POSIX has adopted that. Bash's POSIX mode tries to balance things by both making the value persist and exporting X. Unfortunately this is buggy too as it causes X to continue to be exported after the function returns.

So the bottom-line is that your patch is the correct solution after all :)

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Previous: Eric WongNext: Herbert Xu
Message 7 of 13 in “tests: Remove heredoc usage inside quotes”
  1. 2/4 tests: Remove heredoc usage inside quotesEric Wong, May 26, 2006
  2. 3/4 t5500-fetch-pack: remove local (bashism) usage.Eric Wong, May 26, 2006
  3. 4/4 t6000lib: workaround a possible dash bugEric Wong, May 26, 2006
  4. Herbert XuMay 26, 2006
  5. Herbert XuSep 21, 2007
  6. Eric WongSep 21, 2007
  7. Herbert XuSep 26, 2007
  8. Herbert XuMay 26, 2006
  9. Eric WongMay 29, 2006
  10. Junio C HamanoMay 29, 2006
  11. Herbert XuMay 29, 2006
  12. Herbert XuMay 26, 2006
  13. Eric WongMay 29, 2006

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.