Bash基础:在MacOS上确认版本与升级Bash的方法
发布日期:2021-06-30 20:21:15 浏览次数:2 分类:技术文章

本文共 1699 字,大约阅读时间需要 5 分钟。

这篇文章记录一下在MacOS上Bash版本的确认和升级方法。

目录


事前确认

由于MacOS在新版中已经开始使用zsh作为缺省shell,首先需要确认当前shell是否是Bash,使用如下环境变量即可确认

环境变量:SHELL

liumiaocn:~ liumiao$ echo $SHELL/bin/bashliumiaocn:~ liumiao$

版本确认

使用如下环境变量即可确认BASH的版本信息

环境变量:BASH_VERSION

liumiaocn:~ liumiao$ echo $BASH_VERSION3.2.57(1)-releaseliumiaocn:~ liumiao$

当前稳定版本确认

执行命令:brew info bash

liumiaocn:~ liumiao$ brew info bashbash: stable 5.0.18 (bottled), HEADBourne-Again SHell, a UNIX command interpreterhttps://www.gnu.org/software/bash/Not installedFrom: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/bash.rbLicense: GPL-3.0-or-later==> Options--HEAD	Install HEAD version==> Analyticsinstall: 17,928 (30 days), 54,717 (90 days), 287,380 (365 days)install-on-request: 15,244 (30 days), 46,240 (90 days), 239,390 (365 days)build-error: 0 (30 days)liumiaocn:~ liumiao$

可以看到当前稳定版本为5.0.18

更新BASH

执行命令:brew install bash

liumiaocn:~ liumiao$ brew install bashUpdating Homebrew...==> Downloading https://homebrew.bintray.com/bottles/bash-5.0.18.catalina.bottle.2.tar.gz==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/6a701a90139e32ff22532978c5280548a2d32b96944c2b3cb1beedd912eda827?response-con######################################################################## 100.0%==> Pouring bash-5.0.18.catalina.bottle.2.tar.gz🍺  /usr/local/Cellar/bash/5.0.18: 150 files, 10.3MBliumiaocn:~ liumiao$

因为本文环境使用的sh为3.2的bash,此处安装的bash为5.0,会发现两者共存的情况。

liumiaocn:~ liumiao$ ls -l /bin/sh-rwxr-xr-x  1 root  wheel  31440 Jul 10 06:30 /bin/shliumiaocn:~ liumiao$ liumiaocn:~ liumiao$ bashbash-5.0$ echo $SHELL $BASH_VERSION/bin/bash 5.0.18(1)-releasebash-5.0$ bash-5.0$ shsh-3.2$ echo $SHELL $BASH_VERSION/bin/bash 3.2.57(1)-releasesh-3.2$

转载地址:https://liumiaocn.blog.csdn.net/article/details/110463957 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:版本管理:Subversion Edge:旧版使用OpenJDK的问题和对应方法
下一篇:轻量级容器引擎iSula简介

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月07日 08时44分52秒