Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-22 Thread Michał Górny
On Sat, 21 May 2016 20:45:18 -0400 Mike Frysinger wrote: > On 21 May 2016 17:08, Amadeusz Żołnowski wrote: > > This function is too generic to be in > > rebar.eclass, so I have decided to move it to eutils. What is the > > problem with adding it to eutils? > > because no

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread Mike Frysinger
On 21 May 2016 17:08, Amadeusz Żołnowski wrote: > Mike Frysinger writes: > >> The same "sed -i" is used. I have some configs to edit in place in > >> src_prepare(). It's easier with awk rather than sed. > > > > again, provide an example. one or two uncommon use cases doesn't

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread Amadeusz Żołnowski
Michał Górny writes:> >> +# Following commands should always succeed unless something weird is >> going >> +# on. >> +cat "${tmpf}" >"${f}" || die 'failed to replace source file' || return >> +rm "${tmpf}" || die "failed to remove temporary file" > > Any reason

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread Michał Górny
On Sat, 21 May 2016 14:49:41 +0100 aide...@gentoo.org wrote: > From: Amadeusz Żołnowski > > awk doesn't have the -i option like sed and if editing file in place is > desired, additional steps are required. eawk uses tmp file to make it > look to the caller editing happens in

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread Kristian Fiskerstrand
On 05/21/2016 06:08 PM, Amadeusz Żołnowski wrote: > Mike Frysinger writes: >>> The same "sed -i" is used. I have some configs to edit in place in >>> src_prepare(). It's easier with awk rather than sed. >> >> again, provide an example. one or two uncommon use cases doesn't

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread Amadeusz Żołnowski
Mike Frysinger writes: >> The same "sed -i" is used. I have some configs to edit in place in >> src_prepare(). It's easier with awk rather than sed. > > again, provide an example. one or two uncommon use cases doesn't justify > being added to eutils. See rebar.eclass review

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread Mike Frysinger
On 20 May 2016 21:09, Amadeusz Żołnowski wrote: > Mike Frysinger writes: > > On 18 May 2016 22:25, aide...@gentoo.org wrote: > >> awk doesn't have the -i option like sed and if editing file in place is > >> desired, additional steps are required. eawk uses tmp file to make it >

[gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread aidecoe
From: Amadeusz Żołnowski awk doesn't have the -i option like sed and if editing file in place is desired, additional steps are required. eawk uses tmp file to make it look to the caller editing happens in place. New version of gawk (not stabilized yet) does support editing

[gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread aidecoe
From: Amadeusz Żołnowski awk doesn't have the -i option like sed and if editing file in place is desired, additional steps are required. eawk uses tmp file to make it look to the caller editing happens in place. New version of gawk (not stabilized yet) does support editing

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-21 Thread Amadeusz Żołnowski
Amadeusz Żołnowski writes: > Indeed. So one of these: > > a) eawk > b) eawk -- > c) eawk -- Ups, actually (c) wouldn't be correct either, so only (a) and (b) and I'd just stick to (a) to not complicate things. -- Amadeusz Żołnowski signature.asc Description:

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread rindeal
> a) mawk doesn't support it. > b) 4.1 is not stabilized, yet. a) if you depend on mawk then you can really create your own wrapper in your ebuild or do it inline b) then perhaps put your efforts that way

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread Amadeusz Żołnowski
Mike Frysinger writes: > On 18 May 2016 22:25, aide...@gentoo.org wrote: >> awk doesn't have the -i option like sed and if editing file in place is >> desired, additional steps are required. eawk uses tmp file to make it >> look to the caller editing happens in place. > >

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread Amadeusz Żołnowski
rindeal writes: > Have you guys read > https://stackoverflow.com/questions/16529716/awk-save-modifications-inplace > ? a) mawk doesn't support it. b) 4.1 is not stabilized, yet. -- Amadeusz Żołnowski signature.asc Description: PGP signature

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread rindeal
Reasons for inplace editing are the same for any language and tool, but having a wrapper just because some tool doesn't support it, is a bloat. Especially when gawk>=4.1 supports it.

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread Patrice Clement
Thursday 19 May 2016 23:08:05, Mike Frysinger wrote : > On 18 May 2016 22:25, aide...@gentoo.org wrote: > > awk doesn't have the -i option like sed and if editing file in place is > > desired, additional steps are required. eawk uses tmp file to make it > > look to the caller editing happens in

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread rindeal
Have you guys read https://stackoverflow.com/questions/16529716/awk-save-modifications-inplace ?

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread Amadeusz Żołnowski
"Robin H. Johnson" writes: >> > cp -f "${tmpf}" "$f" || die "copy back failed" >> >> Why '-f' is required? > Corner cases w/ copying and bad ebuild usage (specifically running > ebuild as two different non-root users during development). Mostly > habit. Reading:

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread Amadeusz Żołnowski
Mart Raudsepp writes: > Similarly, I would like that all ebuild that call 'sed' actually DEPEND > on sed, not just half of them. > I would also like that no ebuild would assume packages in @system to be > present, beyond those dictated by PMS (unpackers and such). Please don't

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-20 Thread Ulrich Mueller
> On Thu, 19 May 2016, Amadeusz Żołnowski wrote: > Ulrich Mueller writes: >> Yes, of course. "|| die -n || return" if you want the function to >> return at that point, if it was called under nonfatal. >> >>>

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Mike Frysinger
On 18 May 2016 22:25, aide...@gentoo.org wrote: > awk doesn't have the -i option like sed and if editing file in place is > desired, additional steps are required. eawk uses tmp file to make it > look to the caller editing happens in place. what's your real use case ? i've never once thought

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Mike Frysinger
On 20 May 2016 02:16, Mart Raudsepp wrote: > I would like if such a function would explicitly document that calling > this function means the caller should DEPEND on an awk provider. > Similarly, I would like that all ebuild that call 'sed' actually DEPEND > on sed, not just half of them. > I

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Göktürk Yüksek
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Mart Raudsepp: > Ühel kenal päeval, K, 18.05.2016 kell 22:25, kirjutas > aide...@gentoo.org: >> From: Amadeusz Żołnowski >> >> awk doesn't have the -i option like sed and if editing file in >> place is desired, additional

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Mart Raudsepp
Ühel kenal päeval, K, 18.05.2016 kell 22:25, kirjutas aide...@gentoo.org: > From: Amadeusz Żołnowski > > awk doesn't have the -i option like sed and if editing file in place > is > desired, additional steps are required. eawk uses tmp file to make it > look to the caller

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Robin H. Johnson
On Thu, May 19, 2016 at 10:50:48PM +0100, Amadeusz Żołnowski wrote: > "Robin H. Johnson" writes: > > 1. > > If your AWK command has an error, then this clobbers the file, a > > better variant, with die, would be: > > awk "$@" "$f" >"${tmpf}" || die "awk failed..." > > cp -f

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Amadeusz Żołnowski
"Robin H. Johnson" writes: > 1. > If your AWK command has an error, then this clobbers the file, a > better variant, with die, would be: > awk "$@" "$f" >"${tmpf}" || die "awk failed..." > cp -f "${tmpf}" "$f" || die "copy back failed" Thanks! On the one hand it's a simple

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Amadeusz Żołnowski
Ulrich Mueller writes: > Yes, of course. "|| die -n || return" if you want the function to > return at that point, if it was called under nonfatal. > >> https://blogs.gentoo.org/mgorny/2015/11/13/the-ultimate-guide-to-eapi-6 > > Note that the ${?} in the code example there is

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Ulrich Mueller
> On Thu, 19 May 2016, Mart Raudsepp wrote: >> Ulrich Mueller writes: >> > The EAPI 6 method would be to use "|| die -n". Then the caller >> > either call "eawk" if the function should die automatically, or >> > "nonfatal eawk" if it should return with an error status. >

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Mart Raudsepp
Ühel kenal päeval, N, 19.05.2016 kell 18:51, kirjutas Amadeusz Żołnowski: > Ulrich Mueller writes: > > The EAPI 6 method would be to use "|| die -n". Then the caller can > > either call "eawk" if the function should die automatically, or > > "nonfatal eawk" if it should return

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Amadeusz Żołnowski
Ulrich Mueller writes: > The EAPI 6 method would be to use "|| die -n". Then the caller can > either call "eawk" if the function should die automatically, or > "nonfatal eawk" if it should return with an error status. Yes, that seems better. Hasn't it been introduced earlier

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-19 Thread Ulrich Mueller
> On Wed, 18 May 2016, Amadeusz Żołnowski wrote: >> Also, wouldn't the absence of 'die' cause silent breakages? > I want to caller decide whether die or not and what error messge to > give. The EAPI 6 method would be to use "|| die -n". Then the caller can either call "eawk" if the function

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-18 Thread Göktürk Yüksek
Jeroen Roovers: > On Wed, 18 May 2016 19:31:38 -0400 > Göktürk Yüksek wrote: > >> There could be some performance implications. cat will usually do >> slow, buffered I/O. cp tries to be smarter with allocation, i.e. it >> may take advantage of the btrfs specific clone to do a

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-18 Thread Jeroen Roovers
On Wed, 18 May 2016 19:31:38 -0400 Göktürk Yüksek wrote: > There could be some performance implications. cat will usually do > slow, buffered I/O. cp tries to be smarter with allocation, i.e. it > may take advantage of the btrfs specific clone to do a O(1) copy. Really?

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-18 Thread Göktürk Yüksek
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Amadeusz Żołnowski: > Göktürk Yüksek writes: >>> + cat "${f}" >"${tmpf}" || return 1 >> Why shell redirection with cat instead of cp? both are in >> coreutils. > > I thought cp could overwrite file mode of already existing

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-18 Thread Amadeusz Żołnowski
Göktürk Yüksek writes: >> +cat "${f}" >"${tmpf}" || return 1 > Why shell redirection with cat instead of cp? both are in coreutils. I thought cp could overwrite file mode of already existing tmp file, but actually it doesn't, so cp can be here as well. Is there actual

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-18 Thread Robin H. Johnson
On Wed, May 18, 2016 at 10:25:02PM +0100, aide...@gentoo.org wrote: > From: Amadeusz Żołnowski > > awk doesn't have the -i option like sed and if editing file in place is > desired, additional steps are required. eawk uses tmp file to make it > look to the caller editing

Re: [gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-18 Thread Göktürk Yüksek
aide...@gentoo.org: > From: Amadeusz Żołnowski > > awk doesn't have the -i option like sed and if editing file in place is > desired, additional steps are required. eawk uses tmp file to make it > look to the caller editing happens in place. > --- > eclass/eutils.eclass | 13

[gentoo-dev] [PATCH] eutils.eclass: Add awk wrapper - eawk - edit file in place

2016-05-18 Thread aidecoe
From: Amadeusz Żołnowski awk doesn't have the -i option like sed and if editing file in place is desired, additional steps are required. eawk uses tmp file to make it look to the caller editing happens in place. --- eclass/eutils.eclass | 13 + 1 file changed, 13