Skip to content

Commit

Permalink
shfmt -i 2 -w bin config/{.bin,.config/zsh} install
Browse files Browse the repository at this point in the history
  • Loading branch information
izumin5210 committed May 19, 2024
1 parent e2db9bf commit 00e3bb3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions bin/ln-idempotently
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ set -euo pipefail
cd $(dirname $0)/..

if [ "$#" -ne 2 ]; then
echo "Usage: $0 target_path link_path"
exit 1
echo "Usage: $0 target_path link_path"
exit 1
fi

target_path=$(realpath "$1")
link_path="$2"

# ターゲットパスが存在するかを検証します。
if [ ! -e "${target_path}" ]; then
echo "Error: Target path '${target_path}' does not exist."
exit 1
echo "Error: Target path '${target_path}' does not exist."
exit 1
fi

if [ -L "${link_path}" ]; then
if [ "$(readlink "${link_path}")" = "${target_path}" ]; then
exit 0
fi
if [ "$(readlink "${link_path}")" = "${target_path}" ]; then
exit 0
fi

echo "Error: A different symbolic link already exists at '${link_path}'."
exit 1
echo "Error: A different symbolic link already exists at '${link_path}'."
exit 1
fi

if [ -e "${link_path}" ]; then
echo "Error: A different file or link already exists at '${link_path}'."
exit 1
echo "Error: A different file or link already exists at '${link_path}'."
exit 1
fi

ln -s "${target_path}" "${link_path}"
Expand Down

0 comments on commit 00e3bb3

Please sign in to comment.