Add entry in /etc/shells for a snap

I had someone walk up to me and ask me how you make the powershell snap their shell. Is there a way to add an entry to /etc/shells when the snap is installed?

There’s no specific support in snapd to manage the /etc/shells file.

With that said, as a classic confinement snap there is nothing preventing hooks from modifying files on the base system. A configure hook that ensured your shell was listed in the file, and a remove hook that undid that would probably do the trick.

The debianutils package contains add-shell and remove-shell scripts that could help with this. You can’t rely on them being available on non-Debian derived distros, but you could stage them into your own snap.

3 Likes

I tried using the SNAP variable to calculate the path, but at runtime the path is different than when the hook ran. I guess I could substitute current. Also, I would prefer to use /snap/bin/<name> but not sure if the path varies on different distros.