Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions contrib/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ done
DEST=$1

for SRC in $ARGS; do
# Copy file, then take output of the form 'src' -> 'dest' and get only 'dest'
DESTFILE=$(LC_ALL=C cp -va $SRC $DEST | sed -e $'s/ -> /\\\n/g' | tail -n 1)
cp -a $SRC $DEST

# If there are surrounding quotes, remove them. We do this simply by knowing that the destination is always an absolute path
if [ "$(echo $DESTFILE | head -c1)" != "/" ]; then
DESTFILE=$(echo $DESTFILE | awk '{print substr($0, 2, length($0)-2)}')
if [ -d "$DEST" ]; then
DESTFILE="$DEST/$(basename "$SRC")"
else
DESTFILE="$DEST"
fi

# Do the chmod dance, and ignore errors on platforms that don't like setting permissions of symlinks
# TODO: Test if it's a symlink instead of having to redirect stderr to /dev/null
chmod $PERMS $DESTFILE 2>/dev/null
done