#!/bin/bash

install_version=${1:-"v0.7.1"}
package_name="shellcheck-${install_version}"

# Download
cd /tmp
rm -f ${package_name}.linux.x86_64.tar.xz
wget https://tools.mindspore.cn/tools/check/shellcheck/${package_name}/${package_name}.linux.x86_64.tar.xz
rm -rf ${package_name}
tar -xf ${package_name}.linux.x86_64.tar.xz

# Install
rm -f /usr/bin/shellcheck 
mv /tmp/${package_name}/shellcheck /usr/bin/shellcheck
chmod 755 /usr/bin/shellcheck

# Delete package
rm -rf /tmp/${package_name}
rm -f /tmp/${package_name}.linux.x86_64.tar.xz
