Live data from Hacker News

Use zsh as the default shell on your Mac

support.apple.com

191–200 of 252 posts

Re: Use zsh as the default shell on your Mac

#191

I've never worked outside bash. I have a lot of simple bash scripts. (Usually just stringing together commands with the occasional pipe or output to file) Will this break all those or are bash scripts and zsh scripts basically interchangeable?

I'd recommend to always use just POSIX shell syntax, or at least be aware when you're using bashisms. Bash additions don't buy you much, yet make your script unportable. And using bashisms will get you actually in trouble in practice, since Debian uses dash as default shell, and now Mac OS is using zsh. Considering that shell syntax development has practically ended in 1993, relying on bashisms just isn't worth it.

To be honest I feel like this is throwing the baby out with the bathwater somewhat. If you're writing a script for a system without bash you'll almost certainly know it, so you might as well just put bash in your shebang. I spent a couple of years using #!/bin/sh and avoiding bashisms, but it was literally never useful so I just went back to using #!/usr/bin/env bash.

Of course it goes without saying that you shouldn't use #!/bin/sh then use bash...

Re: Use zsh as the default shell on your Mac

#192
post #15

Earlier quoted context omitted.

Most Terminal users might not even notice the shell changed from Bash to ZSH. Those same users would notice it, had they changed it to Fish.

> Most Terminal users might not even notice the shell changed from Bash to ZSH. If that's an argument in favor of ZSH, I think I've missed the point.

The point is that apple don't want to update bash because they don't want to ship software that uses GPLv3 but they also don't want to keep shipping a decade old version of bash as the default shell, they aren't doing this because they want to improve on bash or anything like that.

Re: Use zsh as the default shell on your Mac

#193

Earlier quoted context omitted.

Sorry, how is that a problem? Users can build and execute code on their own Mac with XCode.

Perhaps Apple's vision for the future is one where you can't do that (ex: App Notarization seems to have us heading in that direction.)

And then who would make software for Apple's platforms? At the end of the day there always has to be a platform that developers can use. You can rest easy; that will never change.

Re: Use zsh as the default shell on your Mac

#195
post #134

Earlier quoted context omitted.

Can we get a modern python version while we're at it?

tip: use pyenv instead

I don't need to run python 2, I'd rather just have the system manage a moderately recent version of python rather than rely on things like pipenv and brew.

Re: Use zsh as the default shell on your Mac

#196
post #103

I've never worked outside bash. I have a lot of simple bash scripts. (Usually just stringing together commands with the occasional pipe or output to file) Will this break all those or are bash scripts and zsh scripts basically interchangeable?

As the other person said, if your scripts are executables with an sh or bash 'shebang' at the top, they will continue to use the same shell they always did. But if you did want to run them with zsh, most simple scripts that just set environment variables, string together commands, or redirect to files should work without any changes. The most obvious difference for basic scripts like that is that zsh doesn't split pa…

>As the other person said, if your scripts are executables with an sh or bash 'shebang' at the top, they will continue to use the same shell they always did.

Cool! I do use shebangs, but my concern is that moving forward bash may not be ported to macOS. (Or will I probably be able to, worst case, compile it myself?)

Re: Use zsh as the default shell on your Mac

#197

I've never worked outside bash. I have a lot of simple bash scripts. (Usually just stringing together commands with the occasional pipe or output to file) Will this break all those or are bash scripts and zsh scripts basically interchangeable?

If they start with a shebang like `#!/usr/bin/env bash` indicating which shell they are written in, it should be fine.

Cool. I have a couple that I forgot to because they're extremely minor (basically just a 4 line set of commands into one) but I can append that easily.

Maybe I'll write a bash script to prep my poorly written bash scripts :D

Re: Use zsh as the default shell on your Mac

#198
post #183

Earlier quoted context omitted.

using a Lenovo P50 with windows 10 for 2 years now, I only reboot it maybe once a month, for the rest, I close the lid, it goes to sleep, next day in the office, I open the lid and continue where I stopped. so far I have had zero issues with it.

That's how I use my mac. Sad to say I've never had that experience with Windows but then again, I've never had a Lenovo ...

What kind of machine do you have?

Re: Use zsh as the default shell on your Mac

#200
post #193

Earlier quoted context omitted.

Perhaps Apple's vision for the future is one where you can't do that (ex: App Notarization seems to have us heading in that direction.)

And then who would make software for Apple's platforms? At the end of the day there always has to be a platform that developers can use. You can rest easy; that will never change.

https://www.gnu.org/philosophy/right-to-read.en.html
Post reply on HN