shfmt安装的几种方式

bash IDE 需要使用shfmt, 下面是shfmt安装的几种方式:

1 使用go安装,这是官方推荐的方式

go install mvdan.cc/sh/v3/cmd/shfmt@latest

2 下载pre-built 的binary

从shfmt的github 的release 页面中(https://github.com/mvdan/sh/releases) 下载最新的pre-built的binary

shtmf_v3.x.x_linux_amd64

将其变成可执行文件然后移动到PATH中

chmod +x shtmf_v3.x.x_linux_amd64

mv shtmf_v3.x.x_linux_amd64 /usr/local/bin/shfmt

3 使用snap(如果有的话)

snap install shfmt

4 从Debian 的repo中

apt install shfmt

5 Build from source

git clone https://github.com/mvdan/sh.git
cd sh
go build ./cmd/shfmt
mv shfmt /usr/local/bin/

 

最后查看版本

shfmt --version