Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On Sat, Feb 13, 2010 at 2:12 PM, Evangelos Foutras foutre...@gmail.com wrote: On 13/02/2010 08:57 μμ, Thomas Bächler wrote: Never use `...`, always $(...), always use the braces for variable names and always quote paths that contain variables. I do not agree with your view that braces should always be used around variable names. While I would like to read any justification about that, my opinion is that they should only be used when necessary. It's a safety net. It will ALWAYS work if you use braces. Not everyone knows what character ends a variable name and what doesn't.
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On 14 February 2010 04:19, Dieter Plaetinck die...@plaetinck.be wrote: On Sat, 13 Feb 2010 16:10:08 -0600 Muhammed Uluyol uluy...@gmail.com wrote: On Sat, Feb 13, 2010 at 4:05 PM, Dieter Plaetinck die...@plaetinck.be wrote: what do you mean context? it only depends on whether the first character after the variablename is a valid character in a variablename or not. if it's valid, use braces. if it isn't, no need for braces. Arrays can't be used with $array[4], they need to be used as ${array[4]} Also finding the string length, substitution, etc require braces okay sure. i agree, but we (or atleast i) were (was) talking about regular variables. We had similar discussions before (I think it was when deciding upon standardising $pkgdir), and the conclusion was: to each his own. We didn't really feel the need to standardise anything; most of us were content with as needed, i.e quotes for when absolute paths are concerned, and braces where characters may interfere or where it is not a variable (array). Until now, I still see: arch=(i686 x86_64) instead of: arch=('i686' 'x86_64') But that makes no difference, aside from maybe treating arch as a pseudo-integer array. Gentoo and ebuilds (although all the other distributions follow similar standards in their scripts) are always the case examples, because they enforce: ${foobar} Keeping it consistent-by-individual should be enough, i.e you don't change your own style across your works, and if you do you should reflect the new style throughout everything else. -- GPG/PGP ID: B42DDCAD
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On 13/02/2010 08:57 μμ, Thomas Bächler wrote: Never use `...`, always $(...), always use the braces for variable names and always quote paths that contain variables. I do not agree with your view that braces should always be used around variable names. While I would like to read any justification about that, my opinion is that they should only be used when necessary. For example, in a PKGBUILD I would write ${pkgname}_$pkgver, because _ can be part of a variable name, but I'd much rather prefer to use $pkgname-$pkgver, since hyphens are not allowed in variable names. Less typing, less ugliness. :)
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On Sat, Feb 13, 2010 at 15:12, Evangelos Foutras foutre...@gmail.com wrote: For example, in a PKGBUILD I would write ${pkgname}_$pkgver, because _ can be part of a variable name, but I'd much rather prefer to use $pkgname-$pkgver, since hyphens are not allowed in variable names. Less typing, less ugliness. :) This is the way I've always done it and it's much nicer to read. Same for quoting, use only when needed.
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On Sat, 13 Feb 2010 15:16:01 -0500 Daenyth Blank daenyth+a...@gmail.com wrote: On Sat, Feb 13, 2010 at 15:12, Evangelos Foutras foutre...@gmail.com wrote: For example, in a PKGBUILD I would write ${pkgname}_$pkgver, because _ can be part of a variable name, but I'd much rather prefer to use $pkgname-$pkgver, since hyphens are not allowed in variable names. Less typing, less ugliness. :) This is the way I've always done it and it's much nicer to read. Same for quoting, use only when needed. +1 for braces around vars only when needed. for quoting I'm not so sure. I personally also only quote when I know it's needed, but when your code is shared with a lot of people it can be useful that other people immediately know that stuff is safe (without them having to know all possible values a certain variable can have)
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
Am 13.02.2010 21:57, schrieb Dieter Plaetinck: For example, in a PKGBUILD I would write ${pkgname}_$pkgver, because _ can be part of a variable name, but I'd much rather prefer to use $pkgname-$pkgver, since hyphens are not allowed in variable names. Less typing, less ugliness. :) This is the way I've always done it and it's much nicer to read. Same for quoting, use only when needed. +1 for braces around vars only when needed. If you use braces only when necessary, it will not be consistent - you have braces sometimes and other times you don't. I thought coding style was about consistency. signature.asc Description: OpenPGP digital signature
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On Sat, 13 Feb 2010 22:11:01 +0100 Thomas Bächler tho...@archlinux.org wrote: Am 13.02.2010 21:57, schrieb Dieter Plaetinck: For example, in a PKGBUILD I would write ${pkgname}_$pkgver, because _ can be part of a variable name, but I'd much rather prefer to use $pkgname-$pkgver, since hyphens are not allowed in variable names. Less typing, less ugliness. :) This is the way I've always done it and it's much nicer to read. Same for quoting, use only when needed. +1 for braces around vars only when needed. If you use braces only when necessary, it will not be consistent - you have braces sometimes and other times you don't. I thought coding style was about consistency. you can apply only when needed consistently.
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On 13/02/2010 11:11 μμ, Thomas Bächler wrote: Am 13.02.2010 21:57, schrieb Dieter Plaetinck: For example, in a PKGBUILD I would write ${pkgname}_$pkgver, because _ can be part of a variable name, but I'd much rather prefer to use $pkgname-$pkgver, since hyphens are not allowed in variable names. Less typing, less ugliness. :) This is the way I've always done it and it's much nicer to read. Same for quoting, use only when needed. +1 for braces around vars only when needed. If you use braces only when necessary, it will not be consistent - you have braces sometimes and other times you don't. I thought coding style was about consistency. As Dieter mentioned, we can use braces when needed and be consistent in this regard. Most of the time they are not needed and I think using them everywhere hinders readability with no obvious benefit.
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
Am 13.02.2010 22:13, schrieb Dieter Plaetinck: If you use braces only when necessary, it will not be consistent - you have braces sometimes and other times you don't. I thought coding style was about consistency. you can apply only when needed consistently. This is very unintuitive. only when needed can even depend on the context, I am strictly against it. signature.asc Description: OpenPGP digital signature
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On Sat, Feb 13, 2010 at 4:05 PM, Dieter Plaetinck die...@plaetinck.be wrote: what do you mean context? it only depends on whether the first character after the variablename is a valid character in a variablename or not. if it's valid, use braces. if it isn't, no need for braces. Arrays can't be used with $array[4], they need to be used as ${array[4]} Also finding the string length, substitution, etc require braces
Re: [arch-general] [arch-dev-public] Let's agree on a common coding style
On Sat, 13 Feb 2010 16:10:08 -0600 Muhammed Uluyol uluy...@gmail.com wrote: On Sat, Feb 13, 2010 at 4:05 PM, Dieter Plaetinck die...@plaetinck.be wrote: what do you mean context? it only depends on whether the first character after the variablename is a valid character in a variablename or not. if it's valid, use braces. if it isn't, no need for braces. Arrays can't be used with $array[4], they need to be used as ${array[4]} Also finding the string length, substitution, etc require braces okay sure. i agree, but we (or atleast i) were (was) talking about regular variables. Dieter