IFS working as expected when in bash, not working properly in zsh

Viewed 219

OS: Monetary (12.0.1)
default shell: zsh (5.8)

#!/bin/zsh

LINE="I:would:like:coffee."
IFS=:
set $LINE

echo $1
echo $2
echo $3
echo $4

exit 0
./script.sh
zsh ./script.sh

Both ways of running the script returned

I:would:like:coffee.

Only when running in bash, did the script work as expected

bash ./script.sh
I
would
like
coffee.

I do want to know that the reason why IFS works as expected in bash, not in zsh.

1 Answers

It looks like ZSH feature. See on ZSH FAQs. For only one script you can use -y flag.

zsh -y ./script.sh
Related