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

Re: [PATCH v4 1/2] git-p4: add test case for "Translation of file content failed" error

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 21, 2015, 23:54 UTC
Message-ID
<CAPig+cRV-RCdcmAHG+bRL6_yYYNCRqQPQ+v3KCXwC81StGKibg@mail.gmail.com>
In-Reply-To
<E47DE9F0-6017-4E96-AC29-E6C60C4D85CB@gmail.com>

On Mon, Sep 21, 2015 at 7:03 PM, Lars Schneider <larsxschneider@gmail.com> wrote:

Show 16 quoted lines
> On 21 Sep 2015, at 20:09, Junio C Hamano <gitster@pobox.com> wrote:
>> larsxschneider@gmail.com writes:
>>> +test_expect_success 'init depot with UTF-16 encoded file and artificially remove BOM' '
>>> +    (
>>> +            cd "db" &&
>>> +            p4d -jc &&
>>> +            # P4D automatically adds a BOM. Remove it here to make the file invalid.
>>> +            sed -e "$ d" depot/file1,v >depot/file1,v.new &&
>>
>> Do you need the space between the address $ (i.e. the last line) and
>> operation 'd' (i.e. delete it)?  I am asking because that looks very
>> unusual at least in our codebase.
>
> Well, I am no “sed” pro. I have to admit that I found this snippet
> on the Internet and it just worked. If I remove the space then it
> does not work. I was not yet able to figure out why… anyone an idea?

Yes, it's because $d is a variable reference, even within double quotes. Typically, one uses single quotes around the sed argument to suppress this sort of undesired behavior. Since the entire test body is already within single quotes, however, changing the sed argument to use single quotes, rather than double, will require escaping them:

    sed -e \'$d\' depot/file...
Aside: You could also drop the unnecessary quotes from the 'cd' argument.
Previous: Lars SchneiderNext: Junio C Hamano
Message 5 of 14 in “git-p4: handle "Translation of file content failed"”
  1. 0/2 git-p4: handle "Translation of file content failed"larsxschneider@gmail.com, Sep 21, 2015
  2. 1/2 git-p4: add test case for "Translation of file content failed" errorlarsxschneider@gmail.com, Sep 21, 2015
  3. Junio C HamanoSep 21, 2015
  4. Lars SchneiderSep 21, 2015
  5. Eric SunshineSep 21, 2015
  6. Junio C HamanoSep 22, 2015
  7. Lars SchneiderSep 22, 2015
  8. Junio C HamanoSep 22, 2015
  9. Michael BlumeSep 22, 2015
  10. Junio C HamanoSep 22, 2015
  11. Lars SchneiderSep 23, 2015
  12. Lars SchneiderSep 22, 2015
  13. Junio C HamanoSep 22, 2015
  14. 2/2 git-p4: handle "Translation of file content failed"larsxschneider@gmail.com, Sep 21, 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.