mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Use portable method to emulate 'readlink -f' behavior
Signed-off-by: Simon Behar <simbeh7@gmail.com>
This commit is contained in:
@@ -43,7 +43,30 @@ if ! test -d "$where"; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
where="$(readlink -f $where)/"
|
# Emulates `readlink -f` behavior, as this is not available by default on MacOS
|
||||||
|
# See: https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
|
||||||
|
function readlink_f {
|
||||||
|
TARGET_FILE=$1
|
||||||
|
|
||||||
|
cd "$(dirname "$TARGET_FILE")"
|
||||||
|
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||||
|
|
||||||
|
# Iterate down a (possible) chain of symlinks
|
||||||
|
while [ -L "$TARGET_FILE" ]
|
||||||
|
do
|
||||||
|
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||||
|
cd "$(dirname "$TARGET_FILE")"
|
||||||
|
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||||
|
done
|
||||||
|
|
||||||
|
# Compute the canonicalized name by finding the physical path
|
||||||
|
# for the directory we're in and appending the target file.
|
||||||
|
PHYS_DIR=$(pwd -P)
|
||||||
|
RESULT=$PHYS_DIR/$TARGET_FILE
|
||||||
|
echo "$RESULT"
|
||||||
|
}
|
||||||
|
|
||||||
|
where="$(readlink_f $where)/"
|
||||||
|
|
||||||
if [ -f "${where}kustomize" ]; then
|
if [ -f "${where}kustomize" ]; then
|
||||||
echo "${where}kustomize exists. Remove it first."
|
echo "${where}kustomize exists. Remove it first."
|
||||||
|
|||||||
Reference in New Issue
Block a user