From: Ian Abbott <abbotti@mev.co.uk>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
Date: Fri, 16 Jun 2023 13:02:10 +0100 [thread overview]
Message-ID: <86b0308b-2cb5-a2ee-4776-43d30231d2d0@mev.co.uk> (raw)
In-Reply-To: <20230616103054.GI18491@pengutronix.de>
Hi Sascha,
On 16/06/2023 11:30, Sascha Hauer wrote:
> On Fri, Jun 16, 2023 at 10:19:38AM +0100, Ian Abbott wrote:
>> On 16/06/2023 07:41, Sascha Hauer wrote:
>>> Hi Ian,
>>>
>>> On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
>>>> If the handoff files were generated on a Windows system, they will have
>>>> DOS line endings. The `indent` program (with the options used by the
>>>> script) does a lousy job tidying up those files, leaving ASCII CR
>>>> characters embedded in the lines. This is particularly bad for array
>>>> initializers that have one value per line, because they all end up on a
>>>> single line with embedded ASCII CR characters between each value.
>>>>
>>>> Add an initial `sed` command to `copy_source()` to match and remove an
>>>> ASCII CR character from the end of each input line.
>>>>
>>>> Also output a message before running `unifdef` and fix the spelling of
>>>> "paths" in one of the other messages.
>>>>
>>>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
>>>> ---
>>>> v2: Corrected tabs in echoed output.
>>>> ---
>>>> scripts/socfpga_import_preloader | 6 +++++-
>>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
>>>> index bd54e1b913..26a8556b1a 100755
>>>> --- a/scripts/socfpga_import_preloader
>>>> +++ b/scripts/socfpga_import_preloader
>>>> @@ -79,6 +79,10 @@ copy_source() {
>>>> cp $src $tgt
>>>> + echo " Translating DOS line endings..."
>>>> + sed -i "s/`echo -e '\r'`$//" $tgt
>>>
>>> Why `echo -e '\r'` here? A plain \r should work as well.
>>
>> A plain \r doesn't work, but \\\r works. I prefer '\r'.
>
> Strange, would be interesting to know where the difference is.
> Here both of these commands have behave the same:
>
> echo hallo | unix2dos | sed "s/`echo -e '\r'`$//" | hexdump -C
> echo hallo | unix2dos | sed "s/\r$//" | hexdump -C
>
> They both result in:
>
> 00000000 68 61 6c 6c 6f 0a |hallo.|
> 00000006
Sorry, I misinterpreted what you wrote. I thought you meant replace
'\r'` with \r, rather than replace `echo -e '\r'` with \r.
I've never seen \r in a sed regular expression before. It seems to be a
GNU sed extension. POSIX only supports \\ and \n.
--
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
next prev parent reply other threads:[~2023-06-16 12:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 13:55 [PATCH] " Ian Abbott
2023-06-15 15:49 ` Ian Abbott
2023-06-15 15:57 ` [PATCH v2] " Ian Abbott
2023-06-16 6:41 ` Sascha Hauer
2023-06-16 9:19 ` Ian Abbott
2023-06-16 10:30 ` Sascha Hauer
2023-06-16 10:36 ` Ahmad Fatoum
2023-06-16 11:31 ` Sascha Hauer
2023-06-16 11:33 ` Sascha Hauer
2023-06-16 12:02 ` Ian Abbott [this message]
2023-06-16 12:31 ` [PATCH v3] " Ian Abbott
2023-06-16 12:35 ` Ahmad Fatoum
2023-06-21 9:34 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86b0308b-2cb5-a2ee-4776-43d30231d2d0@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=barebox@lists.infradead.org \
--cc=sha@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox