public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix.
@ 2013-04-13 14:44 Michał Górny
  2013-04-13 15:52 ` Mike Gilbert
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michał Górny @ 2013-04-13 14:44 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-04-17 18:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-13 14:44 [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix Michał Górny
2013-04-13 15:52 ` Mike Gilbert
2013-04-14 10:37 ` Peter Stuge
2013-04-14 10:46   ` Michał Górny
2013-04-14 11:26     ` Peter Stuge
2013-04-17 18:29       ` Mike Frysinger
2013-04-17 18:30 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox