[core] parse func; gbes; .config/dotfiles/env (#29)

* common.sh: arg parse init

* bug fix

* bug fix

* bug fix. now common.sh won't parse arg autoly

* improve git-branches

* improve git-branches; util-linux

* accelerate ci

* improve gbes; PARSE_ARG_RET

* ci: fix gbes

* ssh: add key ltp1.bd

* Revert "ssh: add key ltp1.bd"

This reverts commit c2433a0549.

* install column; apt -> apt-get

Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
This commit is contained in:
2022-11-17 20:02:35 +08:00
committed by GitHub
parent c354f980bb
commit f39193f28f
6 changed files with 53 additions and 37 deletions

View File

@@ -2,11 +2,7 @@
THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd )
SUDO=''
if [[ "$EUID" != "0" && -x $(command -v sudo) ]]; then
SUDO='sudo'
fi
if [[ -f ~/.config/dotfiles/env ]]; then source ~/.config/dotfiles/env; fi
# Color settings
# Source: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
@@ -101,6 +97,31 @@ setup_color() {
}
# END of color settings
SUDO=''
if [[ "$EUID" != "0" && -x $(command -v sudo) ]]; then
SUDO='sudo'
fi
parse_arg()
{
local ARG=""
PARSE_ARG_RET=()
while [[ $# > 0 || -n "$ARG" ]]; do
if [[ -z "$ARG" ]]; then ARG=$1; shift; fi
case $ARG in
-q*|--quite ) DFS_QUIET=1 ;;
--* ) PARSE_ARG_RET+=("$ARG") ;;
-* ) PARSE_ARG_RET+=("${ARG:0:2}") ;;
* ) PARSE_ARG_RET+=("$ARG") ;;
esac
if [[ "$ARG" == "--"* || ! "$ARG" == "-"* || ${#ARG} -le 2 ]]; then
ARG=""
else
ARG=-${ARG:2}
fi
done
}
ask_for_yN()
{
while [[ -z "$DFS_QUIET" || "$DFS_QUIET" == "0" ]]; do
@@ -170,3 +191,5 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
else
setup_color
fi
unset THIS_DIR_COMMON_SH