I'm working on a function which is intended to analyse result of executing emerge --pretend $package
, and set USE flag in make.conf, and then execute emerge $package
. Example code as below, at line 5, emerge --pretend
worked fine, but at line 13, I got an error emerge: command not found
.
Even if I removed the parenthesis between line 8 and line 15, nothing changed, same error, any idea? If replacing emerge
with echo
, same error, echo: command not found
. It seemed both outside and inside of while
loop are not at the same shell. Why and how to solve that?
Thank you very much!
1 #/bin/bash
2 function emgRecursion() {
3 local result
4 local str
5 result="$(emerge --pretend "="$1 | grep "\[ebuild")"
6 while read -r line
7 do (
8 if [[ $line = *"USE=\""* ]]; then
9 echo "====="
10 else
11 str="${line#*"] "}"
12 str="${str%%" "*}"
13 emerge --pretend "="$str
14 fi
15 ) </dev/tty
16 done <<<"$result"
17 }
18 emgRecursion "sys-cluster/ceph-0.94.4"