chore(style): add shebang, set bash strict mode, create function
[webi-installers/.git] / shfmt / install.sh
1 #!/bin/bash
2 set -e
3 set -u
4
5 function __init_shfmt() {
6
7     ##################
8     # Install shfmt #
9     ##################
10
11     pkg_cmd_name="shfmt"
12
13     pkg_dst_cmd="$HOME/.local/bin/shfmt"
14     pkg_dst="$pkg_dst_cmd"
15
16     pkg_src_cmd="$HOME/.local/opt/shfmt-v$WEBI_VERSION/bin/shfmt"
17     pkg_src_dir="$HOME/.local/opt/shfmt-v$WEBI_VERSION"
18     pkg_src="$pkg_src_cmd"
19
20     pkg_install() {
21         # ~/.local/opt/shfmt-v0.99.9/bin
22         mkdir -p "$(dirname $pkg_src_cmd)"
23         mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
24     }
25
26     pkg_get_current_version() {
27         echo $(shfmt --version 2> /dev/null | head -n 1 | cut -d ' ' -f 2)
28     }
29
30 }
31
32 __init_shfmt