FranckPachot/ybdemo

in gen-yb-docker-compose.sh master_address variable doesn't get generated properly on MacOS Monterey

jaccolandlust opened this issue · 3 comments

Took me some to figure this out. Turns out that the list of master addresses in gen-yb-docker-compose.sh with zsh on macOS Monterey (12.1) isn't generated correctly.

I've changed this:

master_addresses=$(for i in $(seq 0 $(( $number_of_masters - 1)) ) ; do echo "yb-master-$i:7100" ; done | paste -sd,)

into

master_addresses=$(for i in $(seq 0 $(( 3 -1 )) ); do echo "yb-master-$i:7100"; done | tr '\n' ','|rev|cut -c2- | rev)

and then the docker compose does work.

I guess this is because you don't have "paste".
Can you check if this works:

for i in $(seq 0 $(( 3 -1 )) ); do echo "yb-master-$i:7100"; done | awk '{printf s $0 ; s=","}'

I find it easier to read and everybody has awk I guess

Me not sharing the actual error is not cool. Sorry for that.

paste is there, but somehow doesn't accept input from stdin:

master_addresses=$(for i in $(seq 0 $(( $number_of_masters - 1)) ) ; do echo "yb-master-$i:7100" ; done | paste -sd,) usage: paste [-s] [-d delimiters] file ...

Your suggestion works, albeit it ads a % to the output which is highlighted on my terminal. The gen script does work:
for i in $(seq 0 $(( 3 -1 )) ); do echo "yb-master-$i:7100"; done | awk '{printf s $0 ; s=","}'
yb-master-0:7100,yb-master-1:7100,yb-master-2:7100%

really strange that paste doesn't take stdin. I think the '%' is only displayed by zsh.
Well, I'll modify to your solution as I think rev and cut works everywhere. Thanks for the feedback