USE_DOS2UNIX may be more powerful?
Dmitry Marakasov
amdmi3 at mail.ru
Tue Feb 7 15:05:07 PST 2006
* Frank Laszlo (laszlof at vonostingroup.com) wrote:
> Ha, I just noticed it already does this. Look at the code:
I did.
> So you can define it either way..
>
> USE_DOS2UNIX=YES <-- this will parse ALL files within WRKSRC
> USE_DOS2UNIX=foo/*.c bar/biz/*.h <-- this will parse only certain files.
>
> Hope this helps.
That's what I was talking about - if you have many, many directories
with source/header files, and want to convert them all, you'll need
to specify each directory for every file mask. Length of USE_DOS2UNIX
will be number_of_dirs*number_of_filemasks.
If find is used, it may be shortened a lot.
Now when I've given it some thought, I have very simple solution how
power of find can be used without compicated syntax and with very small
changes to bsd.port.mk. The code explains itself:
.if ${USE_DOS2UNIX:U}=="YES"
@${ECHO_MSG} "===> Converting DOS text files to UNIX text files"
@${FIND} -E ${WRKSRC} -type f -print0 | \
${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'
.else
.for f in ${USE_DOS2UNIX}
@${ECHO_MSG} "===> Converting DOS text file to UNIX text file:
${f}"
@if ${ECHO_CMD} '${f}' | ${GREP} / > /dev/null 2>&1; then \
${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'
${WRKSRC}/${f}; \
else \
${FIND} -E ${WRKSRC} -type f -name '${f}' -print0 | \
${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'; \
fi
.endfor
Now, old syntax works as it did:
USE_DOS2UNIX= foo/*.c bar/biz/*.h
will convert all *.c files in ${WRKSRC}/foo/ and all *.h files in
${WRKSRC}/bar/baz/
But, also now we can use
USE_DOS2UNIX= *.c *.h
To convert all *.c and *.h files in all subdirectories under ${WRKSRC}.
For the case when we have many directories and cannot use
USE_DOS2UNIX=YES as it'll corrupt sometring, I think it's the best
solution.
--
Best regards,
Dmitry mailto:amdmi3 at mail.ru
More information about the freebsd-ports
mailing list