[gentoo-dev] Re: How to pass list of paths to eclass?
Peter Volkov wrote: 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 That looks right, although step 1 should *always* be to use the code from step 3. greybot The difference between $@ and $*: without double quotes, none at all: both equal $1 $2 With double quotes, $@ is $1 $2 ..., while $* is expanded as the single argument $1c$2c... (where c is the first character of $IFS). You almost always want $@. The same applies to the expansion of normal arrays. So for most cases, we use [EMAIL PROTECTED] to deal with each element separately, irrespective of its content. The *only* content BASH can't handle is a NUL byte, which is treated as end of string, eg: echo $'foo\0bar' -- pipes between commands are ofc binary safe; you just can't hold raw binary data in shell vars. ${arr[*]} is used for display, eg die Bad params to $FUNCNAME: $* or: oIFS=$IFS; IFS=$'\n'; echo These are the options$IFS${options[*]} IFS=$oIFS # [1] echo ${#IFS} # to check IFS has been restored correctly [1] works fine here, Roy :) func $TAB # needs quotes though, where TAB=$'\t' -- [EMAIL PROTECTED] mailing list
Re: [gentoo-dev] Re: How to pass list of paths to eclass?
В Чтв, 13/12/2007 в 10:52 +, Steve Long пишет: Peter Volkov wrote: 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 That looks right, although step 1 should *always* be to use the code from step 3. No. The idea is to have after first step some kind of backward compatibility. So while we have FONT_CONF=path1 path2 definitions in the tree, when I use them as array bash will expand [EMAIL PROTECTED] in the same way as array with exactly 1 element. And I do not it to be qouted as for cycle should iterate through path{1,2}. I know this does not work with spaces, but current implementations has the same limitation. -- Peter. signature.asc Description: Эта часть сообщения подписана цифровой подписью
[gentoo-dev] Re: How to pass list of paths to eclass?
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? I was also thinking about changing it to a function instead of a variable, so ebuilds would do something like: dofontconfig ${FILESDIR}/50-myconfig ${FILESDIR}/51-myotherconfig dofontconfig() { insinto /etc/fonts/conf.avail/ for conf in $@; do [[ -e ${conf} ]] doins ${conf} done } course this would require a bit of ebuild editing. not many ebuilds use FONT_CONF though. on the other hand, the nicety of the variable is that font ebuilds rarely need to contain a src_install. -- looks like christmas at fifty-five degrees this latitude weakens my knees EFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662 (0xF9A40662) signature.asc Description: OpenPGP digital signature