Re: control-M characters that are NOT end of line characters

2012-01-04 Thread Alan Barrett

On Wed, 04 Jan 2012, James Hartleroad wrote:

But I have a shell script removeCTLM.ksh that has an embedded cntl-m as
part of a regular expression, for example sed 's/^M//g' $file > tmpfile


If this is a shell programming question rather than a subversion
question, then I suggest changing the script to not use an embedded
control-M.  Here are two ways of doing that:

tr -d '\r' <"$infile" >"$outfile"

control_M="$(printf '\r')"
sed -e "s/${control_M}//" <"$infile" >"$outfile"

--apb (Alan Barrett)


Re: control-M characters that are NOT end of line characters

2012-01-04 Thread Daniel Shahaf
David Chapman wrote on Wed, Jan 04, 2012 at 16:11:27 -0800:
> #!/bin/bash -f
> sed 's/\r//g' $1 > tmpfile
> 
> Rather than use a special character, I used the shell's escape sequence.

No you didn't.  The single quotes protect the \ and it is passed
literally to sed's argv[1].

Daniel
(/bin/bash != /bin/sh)


Re: control-M characters that are NOT end of line characters

2012-01-04 Thread David Chapman

On 1/4/2012 12:56 PM, James Hartleroad wrote:


For autopopulate I’ve setup for shell scripts to be text/plain, native 
eol and executable


*.ksh= svn:mime-type=text/plain;svn:eol-style=native;svn:executable

But I have a shell script removeCTLM.ksh that has an embedded cntl-m 
as part of a regular expression, for example sed 's/^M//g' $file > tmpfile


I’ve ended up renaming it to removeCTLM.ksk so I could not include the 
native eol style


*.ksk= svn:mime-type=text/x-ksh;svn:executable

But I’m wondering if anyone has a better solution to this so I don’t 
have to play games with the filetypes to avoid Subversion from 
complaining about the ^M in the file?




It's been awhile since I've played with the Korn shell, but this works 
in bash:


#!/bin/bash -f
sed 's/\r//g' $1 > tmpfile

Rather than use a special character, I used the shell's escape sequence.

--
David Chapman dcchap...@acm.org
Chapman Consulting -- San Jose, CA
Software Development Done Right.
www.chapman-consulting-sj.com



control-M characters that are NOT end of line characters

2012-01-04 Thread James Hartleroad
For autopopulate I’ve setup for shell scripts to be text/plain, native eol
and executable

  *.ksh= svn:mime-type=text/plain;svn:eol-style=native;svn:executable



But I have a shell script removeCTLM.ksh that has an embedded cntl-m as
part of a regular expression, for example sed 's/^M//g' $file > tmpfile



I’ve ended up renaming it to removeCTLM.ksk so I could not include the
native eol style

*.ksk   = svn:mime-type=text/x-ksh;svn:executable



But I’m wondering if anyone has a better solution to this so I don’t have
to play games with the filetypes to avoid Subversion from complaining about
the ^M in the file?