Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 16, 2023 at 12:36:11PM +0200, Ahmad Fatoum wrote:
> Hi,
> 
> On 16.06.23 12: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@xxxxxxxxx>
> >>>> ---
> >>>> 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
> 
> Speaking of unix2dos, socfpga_get_sequencer and socfpga_xml_to_config.sh
> already use dos2unix. Why can't we do likewise here and avoid any
> dash/bash/sed/gsed incompatibilities that might be there?

We could, but you sent a patch that uses sed instead ;)

I'm fine with using dos2unix. I thought you were doing so to avoid
adding another dependency to the barebox build system. In the end
this script is not even part of the build system, but only a helper
script which is called manually, so this shouldn't be a problem.
Also unix2dos/dos2unix is likely found in all Linux distributions. Just
go for it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux