mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-10 08:47:52 +08:00
💐 Sync 2026-06-21 08:49:51
This commit is contained in:
1 parent
3d988e88f2
commit
5fc6434460
9 files changed
+54
-78
No files matched your search
@@ -17,19 +17,9 @@ json_result() {
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
strip_trailing_slashes() {
|
||||
local path="$1"
|
||||
|
||||
while [ "$path" != "/" ] && [ "${path%/}" != "$path" ]; do
|
||||
path="${path%/}"
|
||||
done
|
||||
|
||||
printf '%s\n' "$path"
|
||||
}
|
||||
|
||||
normalize_path() {
|
||||
local path="$1"
|
||||
local old_ifs part normalized parent
|
||||
local part normalized parent
|
||||
|
||||
case "$path" in
|
||||
/*) ;;
|
||||
@@ -37,12 +27,16 @@ normalize_path() {
|
||||
esac
|
||||
|
||||
normalized="/"
|
||||
old_ifs="$IFS"
|
||||
IFS=/
|
||||
set -- $path
|
||||
IFS="$old_ifs"
|
||||
path="${path#/}"
|
||||
|
||||
while [ -n "$path" ]; do
|
||||
part="${path%%/*}"
|
||||
if [ "$part" = "$path" ]; then
|
||||
path=""
|
||||
else
|
||||
path="${path#*/}"
|
||||
fi
|
||||
|
||||
for part in "$@"; do
|
||||
case "$part" in
|
||||
""|.) ;;
|
||||
..)
|
||||
|
||||
Reference in new issue
Block a user