Change default shell of a specific user with awk

I would like to replicate the functionality of chsh (or passwd -e) by awk.
This is what I got so far, but I think there should be an easier way to search and replace field $7 only for lines beginning with user_name:

awk -v user_name="$user_name" -v new_shell="$new_shell" -F: '$1 == user_name { print $1":"$2":"$3":"$4":"$5":"$6":"new_shell};' passwd

Any help is appreciated!

There is no sanity check on the input. You could get a shell that doesn't exist into your passwd. Or is that checked before? Why not use the system commands?

Anyway, a shorter way you can try out:

awk -F":" -v user_name="$user_name" -v new_shell="$new_shell" -F: '$1 == user_name { $7=new_shell; print };' OFS=":" passwd

Thank you very much for your help! I ended up using your solution and it works perfeclty. The input variables are validated before running the awk.

I'm working on a platform independent script and OS commands are different.

Final version:

awk -F":" -v user_name="$user_name" -v new_shell="$new_shell" -F: '$1 == user_name { $7=new_shell }; 1' OFS=":" passwd