True, but all ebuilds are in bash, and eclasses in the tree are supposed to be able to rely on bash being available; forcing that to sh compatibility isn't the right way to get embedded builds imo, and only slows down the rest. A serious embedded developer doesn't build on the target ime. The only other use-case I've heard of that could possibly use it, is building for a PDA or a phone, and again I'd much rather see better desktop/host tools for that, than slowing ebuild/eclass devs down. If you really want portable sh, you don't even use [steveb wrote:Wrong. If you ever have build Gentoo for an embedded system, then you will see that bash is not the number one choice for an shell.
That's called a useless use of cat; grep 'foo' file instead of cat file | grep 'foo'. (I am not looking at the original script, but cat | grep is always one of those ime, and you sound like a beginning shell-scripter; the url will be useful to you, if so.)a.b. wrote:Honestly, I haven't even thought about the possibility that a bashrc might be sourced by anything other than bash so I didn't think about that while writing.
And in at least one place, I could replace use bash's '=~' operator to replace an ugly "cat | grep" construct which I find much worse.
It's called Parameter Expansion. This FAQ shows what you can do with it (the array stuff will not work in sh.)Does that kind of expression have a name I can google for?Code: Select all
while read atom data; do if matchatom "${atom}"; then if [ ${append} -eq 0 ]; then ret="${data%%#*}" else ret="${ret} ${data%%#*}" fi fi done < ${1}
BTW wrapping vars in unnecessary braces is a waste of time. You need to quote "$1" there however as it's a filename. You don't need to quote ret=${data%%#*} as word-splitting does not take place in assignments. You do with the second one as there is a space there. Note you can also use ret+=$foo in general (again the space there would necessitate quoting.)
You can also use if ((append)); then which would swap the meaning of the condition or if ((!append)); if you wanted to keep it as-is. (Assuming append is an integer string.)
http://wooledge.org/mywiki/BashGuide is the place to start if you want to know #bash.
edit: fixed [







