The edos2unix is quite useful when handling DOS-sourced packages.
But since it's a bash function, you can't reasonably use it from within
find invocation. And often you hit packages which are all flooded with
CRLFs that you need to convert.

That's why I'm suggesting to make edos2unix recursive. The posted patch
changes the function to use find+sed for the substitution, passing given
paths as the 'path' arguments to find.

Whenever files are passed, nothing changes for ebuilds. If a directory
is passed, find converts it recursively. The only potential breakage is
when a non-file was passed and something weird was expected of it.

Any thoughts? If nobody opposes, I will commit the patch in 7 days.

---
 gx86/eclass/eutils.eclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gx86/eclass/eutils.eclass b/gx86/eclass/eutils.eclass
index 467cf17..9e3a347 100644
--- a/gx86/eclass/eutils.eclass
+++ b/gx86/eclass/eutils.eclass
@@ -651,15 +651,16 @@ emktemp() {
 }
 
 # @FUNCTION: edos2unix
-# @USAGE: <file> [more files ...]
+# @USAGE: <path> [...]
 # @DESCRIPTION:
 # A handy replacement for dos2unix, recode, fixdos, etc...  This allows you
 # to remove all of these text utilities from DEPEND variables because this
-# is a script based solution.  Just give it a list of files to convert and
-# they will all be changed from the DOS CRLF format to the UNIX LF format.
+# is a script based solution.  Just give it a list of files or directories
+# to convert and they will all be changed from the DOS CRLF format
+# to the UNIX LF format recursively.
 edos2unix() {
        [[ $# -eq 0 ]] && return 0
-       sed -i 's/\r$//' -- "$@" || die
+       find "$@" -type f -exec sed -i 's/\r$//' -- {} + || die
 }
 
 # @FUNCTION: make_desktop_entry
-- 
1.8.1.5


Reply via email to