Re: [gentoo-dev] How to pass list of paths to eclass?
Thank you all, for your responds. Currently I see that the best approach is arrays. They provide required functionality, clear syntax and easy upgrade path. Speaking about the latter it is: 1. Modify eclass to use arrays: for conffile in [EMAIL PROTECTED]; do ... done 2. Modify ebuilds to use arrays. -FONT_CONF=path1 path2 +FONT_CONF=( path1 path2 ) 3. Modify eclass, so that it works with path containing spaces inside: -for conffile in [EMAIL PROTECTED]; do +for conffile in [EMAIL PROTECTED]; do -- Peter. signature.asc Description: Эта часть сообщения подписана цифровой подписью
Re: [gentoo-dev] How to pass list of paths to eclass?
On Thursday 13 December 2007 09:18:45 Peter Volkov wrote: 2. Modify ebuilds to use arrays. -FONT_CONF=path1 path2 +FONT_CONF=( path1 path2 ) Why not use a function in pkg_setup as suggested earlier and pass each path component as $1, $2, etc. Then the ebuild itself doesn't actually care about the storage format of FONT_CONF, whether it's a bash array or a standard string using IFS. That gives you the luxury of changing it as you like without having to change any ebuilds later. pkg_setup() { append_font_conf path1 path2 } Thanks Roy -- [EMAIL PROTECTED] mailing list
Re: [gentoo-dev] How to pass list of paths to eclass?
В Чтв, 13/12/2007 в 09:41 +, Roy Marples пишет: On Thursday 13 December 2007 09:18:45 Peter Volkov wrote: use arrays. Why not use a function in pkg_setup as suggested earlier Because this is more code for the same functionality. Also if at one point somebody decides to add eclass_pkg_setup function to eclass he/she will have to touch all ebuild and put this function into pkg_setup there. BTW. Speaking about font.eclass we already have font_pkg_setup there. So correct code will be: pkg_setup() { font_pkg_setup append_font_conf path1 path2 } instead of on line FONT_CONF=( path1 path2 ) -- Peter. signature.asc Description: Эта часть сообщения подписана цифровой подписью
Re: [gentoo-dev] How to pass list of paths to eclass?
On Dec 11, 2007 8:17 AM, Peter Volkov [EMAIL PROTECTED] wrote: Hello. Some eclasses (kernel-2, font) use variable to pass space separated PATH to patch or fontconfig files from ebuild to eclass. In ebuild we use: FONT_CONF=path1 path2 Then eclasses use the variable: for conffile in ${FONT_CONF}; do ... done The problem with this doesn't work if path{1,2} contain spaces. The solution I'm thinking about is to you arrays: FONT_CONF=(path1 path2) for conffile in [EMAIL PROTECTED]; do ... done But is this good idea? Are there better? -- Peter. I agree using arrays would be much better, you can also loop through the arrays like. for ((i=0;i${#FONT_CONF[*]};i++)); do echo ${FONT_CONF[i]}; done this way you can avoid spacing because you'll just be calling each array element in order using quotes. Fernando
Re: [gentoo-dev] How to pass list of paths to eclass?
On 11:17 Tue 11 Dec , Peter Volkov wrote: FONT_CONF=(path1 path2) for conffile in [EMAIL PROTECTED]; do ... done But is this good idea? Are there better? Roy solved a similar problem in baselayout-2 using hardcoded newlines, although it had the additional constraint of sh compatibility. It's worth considering code clarity between that and arrays. Thanks, Donnie -- [EMAIL PROTECTED] mailing list
Re: [gentoo-dev] How to pass list of paths to eclass?
On Tuesday 11 December 2007 08:17:12 Peter Volkov wrote: Some eclasses (kernel-2, font) use variable to pass space separated PATH to patch or fontconfig files from ebuild to eclass. In ebuild we use: FONT_CONF=path1 path2 Then eclasses use the variable: for conffile in ${FONT_CONF}; do ... done The problem with this doesn't work if path{1,2} contain spaces. The solution I'm thinking about is to you arrays: FONT_CONF=(path1 path2) for conffile in [EMAIL PROTECTED]; do ... done But is this good idea? Are there better? FONT_CONF=path1:path2 IFS=. for for conffile in ${FONT_CONF}; do done unset IFS Or if you want to be really picky about preserving IFS if you can't make it local in a function SIFS=${IFS-y} OIFS=${IFS} IFS=. for for conffile in ${FONT_CONF}; do done if [ ${SIFS} = y ]; then unset IFS else IFS=${OIFS} fi That way you work the same way as the classic $PATH variable. But of course no one cares as it's Just Not Bash (tm) Thanks Roy -- [EMAIL PROTECTED] mailing list
Re: [gentoo-dev] How to pass list of paths to eclass?
On Tuesday 11 December 2007 08:44:51 Donnie Berkholz wrote: Roy solved a similar problem in baselayout-2 using hardcoded newlines, although it had the additional constraint of sh compatibility. It's worth considering code clarity between that and arrays. Only because some commands could litterally have any character in then, making things a little tricky. Here I see no reason why it cannot behave like $PATH and operate under the same constraints. Thanks Roy -- [EMAIL PROTECTED] mailing list
Re: [gentoo-dev] How to pass list of paths to eclass?
В Втр, 11/12/2007 в 10:38 +, Roy Marples пишет: FONT_CONF=path1:path2 IFS=. IIUC should be IFS=: for for conffile in ${FONT_CONF}; do done unset IFS That way you work the same way as the classic $PATH variable. But this seems to fail if we have ':' inside path{1,2}. Is that true? For PATH the same question stands, but I think that ':' is used there for historical reasons. -- Peter. signature.asc Description: Эта часть сообщения подписана цифровой подписью
Re: [gentoo-dev] How to pass list of paths to eclass?
On Tuesday 11 December 2007 11:14:49 Peter Volkov wrote: That way you work the same way as the classic $PATH variable. But this seems to fail if we have ':' inside path{1,2}. Is that true? For PATH the same question stands, but I think that ':' is used there for historical reasons. Yes, that does mean you cannot use : in PATH. I don't actually know if shells allow it to be escaped, but I do know that escaping does not work when IFS is concerned. You could also use the embedded newline approach that Donnie mentioned earlier, but you may or may not want to go there. It's it's fairly ugly code. But the good news is you can now escape anything into an item, and remian shell portable. Here's a code snippet FONT_CONF=conf1 conf2 SIFS=${IFS-y} OIFS=${IFS} IFS= for for conffile in ${FONT_CONF}; do done if [ ${SIFS} = y ]; then unset IFS else IFS=${OIFS} fi Oddly enough, you do need to quote variable assignment now as in my test even bash got it wrong. Probably a bug, but heh. Thanks Roy -- [EMAIL PROTECTED] mailing list