* [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
* Re: [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix.
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-17 18:30 ` Mike Frysinger
2 siblings, 0 replies; 7+ messages in thread
From: Mike Gilbert @ 2013-04-13 15:52 UTC (permalink / raw
To: Gentoo Dev
On Sat, Apr 13, 2013 at 10:44 AM, Michał Górny <mgorny@gentoo.org> wrote:
> 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.
>
If used improperly, this could easily end up breaking binary files
that happen to contain the '\r' byte. Maybe a DEPEND on dos2unix would
be a better option in the case where many files must be converted.
I don't think it is necessary to convert DOS text files unless they
somehow break on a UNIX system. Shell scripts are a good example, as
well as some autotools files. No need to convert README though.
I would guess that this patch is a response to bug 465790. I'm ok with
requiring that python scripts be in UNIX format, although the python
interpreter seems to work with either format.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix.
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-17 18:30 ` Mike Frysinger
2 siblings, 1 reply; 7+ messages in thread
From: Peter Stuge @ 2013-04-14 10:37 UTC (permalink / raw
To: gentoo-dev
Michał Górny wrote:
> Any thoughts?
If doing this at all I think it should take an -r option to enable
the new recursion, for symmetry with the do* functions and for
backwards compatibility.
//Peter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix.
2013-04-14 10:37 ` Peter Stuge
@ 2013-04-14 10:46 ` Michał Górny
2013-04-14 11:26 ` Peter Stuge
0 siblings, 1 reply; 7+ messages in thread
From: Michał Górny @ 2013-04-14 10:46 UTC (permalink / raw
To: gentoo-dev; +Cc: peter
[-- Attachment #1: Type: text/plain, Size: 363 bytes --]
On Sun, 14 Apr 2013 12:37:05 +0200
Peter Stuge <peter@stuge.se> wrote:
> Michał Górny wrote:
> > Any thoughts?
>
> If doing this at all I think it should take an -r option to enable
> the new recursion, for symmetry with the do* functions and for
> backwards compatibility.
Backwards compatibility with what?
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix.
2013-04-14 10:46 ` Michał Górny
@ 2013-04-14 11:26 ` Peter Stuge
2013-04-17 18:29 ` Mike Frysinger
0 siblings, 1 reply; 7+ messages in thread
From: Peter Stuge @ 2013-04-14 11:26 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 519 bytes --]
Michał Górny wrote:
> > > Any thoughts?
> >
> > If doing this at all I think it should take an -r option to enable
> > the new recursion, for symmetry with the do* functions and for
> > backwards compatibility.
>
> Backwards compatibility with what?
With the old non-recursive behavior of edos2unix that could only
operate on a single file.
Arguably, all old users *should* have refered to single files, but I
would still prefer adding a -r just to be sure to avoid collateral
damage.
//Peter
[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix.
2013-04-14 11:26 ` Peter Stuge
@ 2013-04-17 18:29 ` Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2013-04-17 18:29 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: Text/Plain, Size: 712 bytes --]
On Sunday 14 April 2013 07:26:26 Peter Stuge wrote:
> Michał Górny wrote:
> > > > Any thoughts?
> > >
> > > If doing this at all I think it should take an -r option to enable
> > > the new recursion, for symmetry with the do* functions and for
> > > backwards compatibility.
> >
> > Backwards compatibility with what?
>
> With the old non-recursive behavior of edos2unix that could only
> operate on a single file.
>
> Arguably, all old users *should* have refered to single files, but I
> would still prefer adding a -r just to be sure to avoid collateral
> damage.
if you run the current edos2unix on a dir, it'll fail. so i don't think
backwards compat is a big worry here.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH eutils] Support recursive operation in edos2unix.
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-17 18:30 ` Mike Frysinger
2 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2013-04-17 18:30 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: Text/Plain, Size: 801 bytes --]
On Saturday 13 April 2013 10:44:20 Michał Górny wrote:
> 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.
i'm ambivalent on requiring the -r flag, so this LGTM as is
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [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