Another approach would be to get rid of the control character in the program first; this may have other compatibility benefits and may avoid editing problems in the future.
You can easily generate \r in bash with
`printf '%b' '\015'`
So for example:
$ echo abc`printf %b '\015'`def def $
Or:
$ c=`printf %b '\015'` $ set | grep ^c= c=$'\r' $
(Note: I know that there are simpler methods than calling printf. Unfortunately, these simple methods differ in bash and posix shells. The bash solution is pretty simple: $'\r' . Even nicer: c='\r . I'm not sure ash does this because he is angry or because he is posix.)
Digitaloss
source share