1 Star 0 Fork 18

hos-learning/third_party_cups-filters

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ln-srf 855 Bytes
一键复制 编辑 原始数据 按行查看 历史
#!/bin/sh
#
# Author: Carlos Santos <unixmania@gmail.com>
# This file is in public domain.
#
error() {
echo "$@" 1>&2
exit 1
}
src="$1"
dst="$2"
check_path() {
case "$2" in
*/../*|*/./*|*/.|*/..) error "$1 path '$2' must be absolute";;
*/) error "$1 path '$2' must not end with '/'";;
/?*) ;;
*) error "$1 path '$2' must start with '/'";;
esac
}
check_path "source" "$src"
check_path "destination" "$dst"
# strip leading '/'
src=${src#/*}
tmp=${dst#/*}
s_prefix=${src%%/*}
d_prefix=${tmp%%/*}
# strip leading common
while [ "$s_prefix" = "$d_prefix" ]; do
src="${src#$s_prefix/}"
tmp="${tmp#$d_prefix/}"
s_prefix=${src%%/*}
d_prefix=${tmp%%/*}
done
s_prefix="../"
while [ -n "$d_prefix" ] && [ "$tmp" != "$d_prefix" ]; do
s_prefix="../$s_prefix"
tmp="${tmp#$d_prefix/}"
d_prefix=${tmp%%/*}
done
ln -s -f "$s_prefix$src" "$dst"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hos-learning/third_party_cups-filters.git
git@gitee.com:hos-learning/third_party_cups-filters.git
hos-learning
third_party_cups-filters
third_party_cups-filters
master

搜索帮助