Skip to content

Commit

Permalink
realpath usage: Don't require symlink dest to exist when resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
andsens committed Sep 18, 2023
1 parent 699074a commit 2be76a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Replace `bash -c ...` with `sudo bash -c ...` to install system-wide.
You can also paste this directly into a Dockerfile `RUN` command, no escaping needed.

```
wget -qO- https://raw.githubusercontent.com/orbit-online/upkg/v0.11.0/upkg.sh | (\
wget -qO- https://raw.githubusercontent.com/orbit-online/upkg/v0.11.1/upkg.sh | (\
set +e; IFS='' read -r -d $'\0' src; set -e;\
printf '%s' "$src" | shasum -a 256 -c <(printf '30f5315b882bb2577ff783042ee75f9ed005d04a8b52ec4adc851205874e8db9 -');\
printf '%s' "$src" | shasum -a 256 -c <(printf '43298eaec88ae0d116e2f49934de266b7a93f72c52929a8bd0edb4a3b4aacd36 -');\
bash -c "set - install -g orbit-online/upkg@v0.11.0; $src")
```

Expand Down
6 changes: 3 additions & 3 deletions upkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ upkg_install() {
fatal "Error on command '%s' in package %s@%s. The command may not contain spaces or slashes" \
"$command" "$pkgname" "$pkgversion"
cmdpath="$binpath/$command"
if [[ -e $cmdpath || -L $cmdpath ]] && [[ $(realpath "$cmdpath" 2>/dev/null || true) != $pkgpath/* ]]; then
if [[ -e $cmdpath || -L $cmdpath ]] && [[ $(realpath -m "$cmdpath") != $pkgpath/* ]]; then
fatal "Error on command '%s' in package %s@%s. The 'bin/' file/symlink exists \
and does not point to the package" "$command" "$pkgname" "$pkgversion"
fi
Expand Down Expand Up @@ -200,7 +200,7 @@ upkg_uninstall() {
while [[ -n $commands ]] && read -r -d $'\n' command; do
read -r -d $'\n' asset
cmdpath="$binpath/$command"
[[ ! -e $cmdpath || $(realpath "$cmdpath") != $pkgpath/* ]] || rm "$cmdpath"
[[ ! -e $cmdpath || $(realpath -m "$cmdpath") != $pkgpath/* ]] || rm "$cmdpath"
done <<<"$commands"
if [[ -n $deps_to_remove ]]; then
find "$pkgpath" -mindepth 1 -maxdepth 1 -path "$pkgpath/.upkg" -prune -o -exec rm -rf \{\} \;
Expand Down Expand Up @@ -229,7 +229,7 @@ upkg_list() {

upkg_root() (
local sourcing_file=$1
[[ -z $sourcing_file ]] || cd "$(dirname "$(realpath "${sourcing_file}")")"
[[ -z $sourcing_file ]] || cd "$(dirname "$(realpath -m "${sourcing_file}")")"
until [[ -e $PWD/upkg.json ]]; do
[[ $PWD != '/' ]] || fatal 'Unable to find package root (no upkg.json found in this or any parent directory)'
cd ..
Expand Down

0 comments on commit 2be76a9

Please sign in to comment.