[plug] Does anyone know where i can get source for dos2unix?

Oliver White ojw at iinet.net.au
Tue May 25 21:50:55 WST 1999


*golf clap* :-)

Yeah, I know my system clock is wrong, have tried numorous times to set it
correctly, and have asked a couple of times on the list how it's done
(synching with a time server, why the hell someone gave me a sydney one on
the PLUG list I do not know). See you tommorow mate :-)

Christian wrote:

> Oliver White wrote:
> >
> > Nice, but can you make it recursive (for use on source trees)?
>
> Maybe...
>
> #!/usr/bin/perl
>
> if(not scalar @ARGV)
> {
>         while(<>)
>         {
>                 s/\r//;
>                 print;
>         }
> }
> else
> {
> foreach $file (@ARGV)
> {
>         open FH, "+>$file" or die "Can't open $file for r/w: $!\n";
>         while(<FH>)
>         {
>                 s/\r//;
>                 push @lines, $_;
>         }
>
>         seek FH, 0, 0;
>         foreach (@lines)
>         {
>                 print FH $_;
>         }
>
>         undef @lines;
>         close FH;
> }
> }
>
> This will either read from the standard input and write to the standard
> output (and thus can be used as a filter) if it is not given the any
> command line parameters.  However if you give it command line parameters
> then it will treat each as a filename and open that file, remove the
> offending \r's and then go on to the next file.
>
> Therefore if you want it to behave recursively you could then use
> find(1) to pass this program it's parameters.  Assuming the above is
> called mydos2unix then, for example...
>
> mydos2unix `find /start/here`
>
> Note that with this extra functionality it's about the same length as
> the original C program. :)
>
> BTW mate, I think your system clock is wrong or something... about 3
> hours behind?
>
> Cya,
>
> Christian.
>
> --
> ========================================================================
> I'm not trying to give users what they want, I'm trying to give them
> freedom, which they can then accept or reject. If people don't want
> freedom, they may be out of luck with me, but I won't allow them to
> define for me what is right, what is worth spending my life for.
>                                                     - Richard Stallman



More information about the plug mailing list