-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[features]: Shell Script Optimization #68
Labels
feature | 功能
New feature or request
Comments
浅改了一下脚本 不知道逻辑之类的对不对、有没有语法错误 #!/bin/bash
# 这里用 -z 判断是否已经被赋值
# 这代表用户也可以自由配置这些变量
# 如果不想用户配置 可以删掉条件判断
[ -z "$XLINGS_DIR" ] && XLINGS_DIR="$(realpath "$(dirname "$0")/..")" # 这里直接获取了脚本的上级目录
[ -z "$XLINGS_RUN_DIR" ] && XLINGS_RUN_DIR="$(pwd)" # 或者 "$PWD"
[ -z "$XLINGS_CACHE_DIR" ] && XLINGS_CACHE_DIR="$XLINGS_RUN_DIR/.xlings"
[ -z "$XLINGS_PROJECT_CONFIG_FILE" ] && XLINGS_PROJECT_CONFIG_FILE="$XLINGS_RUN_DIR/config.xlings"
# 可以将参数全部传给 xlings
# 在 lua 代码中获取环境变量
# 在 lua 代码中完成所有以下逻辑
# cd $XLINGS_DIR/core
# export XLINGS_DIR XLINGS_RUN_DIR XLINGS_CACHE_DIR XLINGS_PROJECT_CONFIG_FILE
# xmake xlings "$@"
# (删除 $XLINGS_RUN_DIR 是因为这也被设置为了导出的变量 可以被获取)
# 或者 使用 shell 完成部分预处理工作
# 存在 config.xlings 文件时 仍然正常执行的 subcommands
COMMON_CMDS+=(-h help uninstall update drepo config)
COMMON_CMD=; for cmd in "${COMMON_CMDS[@]}"; do [[ "$1" == "$cmd" ]] && COMMON_CMD=1 && break; done
mkdir -p "$XLINGS_CACHE_DIR";
if [[ ! "$COMMON_CMD" && -f "$XLINGS_PROJECT_CONFIG_FILE" ]]; then
# Project SubCommands
# 看不懂 照搬的
cp -f "$XLINGS_PROJECT_CONFIG_FILE" "$XLINGS_CACHE_DIR/config-xlings.lua"
cp -f "$XLINGS_DIR/tools/template.linux.xlings" "$XLINGS_CACHE_DIR/xmake.lua"
cd "$XLINGS_CACHE_DIR"
xmake l config-xlings.lua || exit $?
xmake xlings "$XLINGS_RUN_DIR" "$@" || exit $?
exit 0
fi
# Common SubCommands
cd "$XLINGS_DIR/core"
xmake xlings "$XLINGS_RUN_DIR" "$@" |
Sunrisepeak
added a commit
that referenced
this issue
Jan 10, 2025
- #68 0. update script 1. remove short-command file 2. use xvm create command alias 3. update xvm Signed-off-by: sunrisepeak <[email protected]>
Sunrisepeak
added a commit
that referenced
this issue
Jan 21, 2025
- #68 1. optimize xlings and xlings.bat 2. adjust xrun to xchecker dir Signed-off-by: sunrisepeak <[email protected]>
Sunrisepeak
added a commit
that referenced
this issue
Jan 21, 2025
- #68 1. optimize xlings and xlings.bat 2. adjust xrun to xchecker dir Signed-off-by: sunrisepeak <[email protected]>
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如题 优化短命令的实现
(看了关于此项目短命令的视频后特意看了一下)
此处以
xim (.sh)
的实现举例目前已知问题
建议的实现:
The text was updated successfully, but these errors were encountered: