bug-sed
[Top][All Lists]
Advanced

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

bug#26879: end-of-line issue with cygwin 4.4-1 sed 4.4


From: Dick Dunbar
Subject: bug#26879: end-of-line issue with cygwin 4.4-1 sed 4.4
Date: Mon, 15 May 2017 15:55:44 -0700

You've been generous and patient.  Thanks Eric.  Especially appreciate
those url's.
Still avoiding cygwin list because this is universal; Peace on Earth
restored.


1. bash-on-linux-on-windows ... is ubuntu ported distro.
   $ uname -r
      4.4.0-43-Microsoft
   $ echo $TERM
      xterm-256color
   $ sudo apt install dos2unix
   $ winpgm | head -5 > x.out
   $ vi x.out    ## vi identifies it as "dos" file

2. Windows WSL ends each output line with "#" ; (  it's not term related.
cygwin does too )

    $ alias od="/usr/bin/od -tx1z"     ## I like your choice. I have a
similar debugging .h file
    $ od x.out | head -6

    0000000 43 3a 5c 54 6f 6f 6c 73 5c 4d 69 63 72 6f 73 6f
>C:\Tools\Microso<
    0000020 66 74 20 56 69 73 75 61 6c 20 53 74 75 64 69 6f  >ft Visual
Studio<
    0000040 5c 32 30 31 37 5c 43 6f 6d 6d 75 6e 69 74 79 5c
>\2017\Community\<
    0000060 57 65 62 5c 45 78 74 65 72 6e 61 6c 5c 6e 6f 64
>Web\External\nod<
    0000100 65 5f 6d 6f 64 75 6c 65 73 5c 65 73 35 2d 65 78
>e_modules\es5-ex<
    0000120 74 5c 61 72 72 61 79 5c 23 0d 0a 43 3a 5c 54 6f
>t\array\#..C:\To<

3. A universal filter for windows might look like this:

   Encapsulated in a sed file filter ( because bash/alias quoting is too
obscure )
   $ cat ~/qt.sed
     #!/bin/sh
     dos2unix | sed -e "s/\#$//" -e "s/^.*/'&'/"

  Also works with Mac files.
   $ cat ~/qtm.sed
     #!/bin/sh
     dos2unix -c mac| sed -e "s/\#$//" -e "s/^.*/'&'/"

   $ chmod +x *.sed

   $ cat ~/.alias
     alias qt='~/qt.sed'
     alias qtm='~/qtm.sed'

   $ source .alias

    $ cat x.out | qt      ## Works on native linux (\n) output too

    $ touch 'phuny #1 file'

    $ ls -1 ph* |dos2unix |sed -e "s/\#$//" -e "s/^.*/'&'/"
      'phuny #1 file'
      'physmem.exe'

   $ ls -1 | qt    # works
   $ ls -1 |qtm  # also works on linux


4. The resolution works on Ubuntu 16.04 (  VirtualBox installation )
     $ uname -r
        4.8.0-51.generic
     $ sudo apt install dos2unix

It's resolved in a straight-forward  and robust way.  Thanks for the help.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]