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

Re: Weird problem with git-submodule.sh

From
Marc Branchaud <marcnarc@xiplink.com>
Date
Dec 7, 2012, 21:01 UTC
Message-ID
<50C25934.4080409@xiplink.com>
In-Reply-To
<7vsj7hfw6q.fsf@alter.siamese.dyndns.org>
On 12-12-07 03:23 PM, Junio C Hamano wrote:
Show 33 quoted lines
> Marc Branchaud <marcnarc@xiplink.com> writes:
> 
>>     sh-setup: protect from exported IFS
>>
>>     Many scripted Porcelains rely on being able to split words at the
>>     default $IFS characters, i.e. SP, HT and LF.  If the user exports a
>>     non-default IFS to the environment, what they read from plumbing
>>     commands such as ls-files that use HT to delimit fields may not be
>>     split in the way we expect.
>>
>>     Protect ourselves by resetting it, just like we do so against CDPATH
>>     exported to the environment.
>>
>>     Noticed by Andrew Dranse <adranse@oanda.com>.
>>
>>     Signed-off-by: Junio C Hamano <gitster@pobox.com>
>>
>> Perhaps IFS should be set to " \t\n" (which I believe is sh's default)
>> instead of just unsetting it altogether?
> 
> POSIX.1 says this:
> 
>     IFS - A string treated as a list of characters that is used for
>     field splitting and to split lines into fields with the read
>     command.  If IFS is not set, it shall behave as normal for an
>     unset variable, except that field splitting by the shell and
>     line splitting by the read command shall be performed as if the
>     value of IFS is <space> <tab> <newline>; see Field Splitting.
> 
>     Implementations may ignore the value of IFS in the environment, or
>     the absence of IFS from the environment, at the time the shell is
>     invoked, in which case the shell shall set IFS to <space> <tab>
>     <newline> when it is invoked.

Not to defend anyone, but I can understand how an implementer might think they're complying with the above while still deciding that an explicit "unset IFS" means IFS=''.

		M.
Previous: Phil HordNext: marcnarc@xiplink.com
Message 18 of 19 in “Weird problem with git-submodule.sh”
  1. Marc BranchaudDec 7, 2012
  2. Junio C HamanoDec 7, 2012
  3. Marc BranchaudDec 7, 2012
  4. Junio C HamanoDec 7, 2012
  5. Marc BranchaudDec 7, 2012
  6. Junio C HamanoDec 7, 2012
  7. Marc BranchaudDec 7, 2012
  8. Junio C HamanoDec 7, 2012
  9. sh-setup: work around "unset IFS" bug in some shellsJunio C Hamano, Dec 7, 2012
  10. Marc BranchaudDec 7, 2012
  11. Andreas SchwabDec 7, 2012
  12. Junio C HamanoDec 7, 2012
  13. Andreas SchwabDec 8, 2012
  14. Stefano LattariniDec 9, 2012
  15. Phil HordDec 12, 2012
  16. Junio C HamanoDec 12, 2012
  17. Phil HordDec 12, 2012
  18. Marc BranchaudDec 7, 2012
  19. sh-setup: Explicitly set IFS to its default, instead of unsetting it.marcnarc@xiplink.com, Dec 7, 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.