Categories
Mac admin'ing

Scripting changing user icons: dsimport prompts for password in zsh

Apple is moving toward making zsh the default shell instead of bash, and it may even eventually remove bash completely from being preinstalled on macOS.

So lots of Mac admins are working to revise scripts from bash to zsh.

Last year, I blogged about Scripting changing the user picture in macOS and referenced this script in particular, which works wonders… that is, unless you try to switch it to zsh.

If you run it as is (using bash), it changes the user picture just fine:

dscl . delete /Users/username JPEGPhoto
dscl . delete /Users/username Picture
userpic.sh username /Library/User\ Pictures/Animals/Zebra.tif

Successfully imported users picture.

If you switch it to zsh, though, it gets permission is denied and then prompts for the password of the user whose picture you’re trying to change:

dscl . delete /Users/username JPEGPhoto
dscl . delete /Users/username Picture
userpic.sh username /Library/User\ Pictures/Animals/Zebra.tif

/usr/local/bin/userpic.sh:16: permission denied: /Library/Caches/username.picture.dsimport
username's password:

So for now, unless someone comments below “Oh, you just need to change this line to get it to work in zsh,” I would hold off on switching that script over to zsh.

Leave a Reply

Your email address will not be published. Required fields are marked *