From 91c81961ff8367f31e7293472c2c6fe260ebb80d Mon Sep 17 00:00:00 2001 From: voidint Date: Sun, 12 May 2024 11:02:29 +0800 Subject: [PATCH] refactor: simplified installation script --- install.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index f509d98..7409f84 100755 --- a/install.sh +++ b/install.sh @@ -29,7 +29,7 @@ function get_os() { echo $(uname -s | awk '{print tolower($0)}') } -main() { +function main() { local release="1.6.0" local os=$(get_os) local arch=$(get_arch) @@ -61,19 +61,17 @@ export G_MIRROR=https://golang.google.cn/dl/ if [ -x "$(command -v bash)" ]; then cat >>${HOME}/.bashrc <<-'EOF' -# g shell setup -if [ -f "${HOME}/.g/env" ]; then - . "${HOME}/.g/env" -fi + +[ -s "${HOME}/.g/env" ] && \. "${HOME}/.g/env" # g shell setup + EOF fi if [ -x "$(command -v zsh)" ]; then cat >>${HOME}/.zshrc <<-'EOF' -# g shell setup -if [ -f "${HOME}/.g/env" ]; then - . "${HOME}/.g/env" -fi + +[ -s "${HOME}/.g/env" ] && \. "${HOME}/.g/env" # g shell setup + EOF fi