Bash on OSX versus Bash on Ubuntu and Upgrading Your Bash
source link: https://fuzzyblog.io/blog/osx/2017/02/15/bash-on-osx-versus-bash-on-ubuntu.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Bash on OSX versus Bash on Ubuntu and Upgrading Your Bash
Feb 15, 2017
Bash is one of those things that you just don't think about all that much – until you want something that is apparently new. In my case I was looking to use the ** syntax which, mysteriously, I found doesn't work at all on OSX (even if you turn it on). This let me to use bash –version.
Here's the result for Linux:
bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Here's the result for OSX:
bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.
Intellectually I've always known that OSX lagged behind on Open Source tooling but 6 years behind??? Really??? Apparently this is a GPL v3 issue so I get it but sigh.
Upgrading Bash on OSX
I will admit that I am absolutely terrified to try upgrading Bash on OSX since I eat, sleep and breathe in the terminal. The research I've done shows me that you can upgrade your Bash to a version 4 series with just this brew command:
brew install bash
And HomeBrew is awesome so I suspect it works; I'm just chicken.
Sidebar: The ** Syntax Explained
The ** syntax allows the file globbing to operate recursively with a single command. For example:
wc -l **/*.rb
would count all the lines of ruby code across all subdirectories. If you haven't enabled ** then you can do this with:
shopt -s globstar
I first the ** syntax on Stack Overflow here. Thank you Michael Wild.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK