Skip to content

Commit 6de9e97

Browse files
albaptkelman
authored andcommitted
Simplify install.sh (take 2) (#16829)
* Simplify install.sh * fix install.sh * fix install.sh * support installing to a file as well as a directory * forgot to remove one line * typos * fix indentation
1 parent 47386ea commit 6de9e97

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

contrib/install.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ done
1515
DEST=$1
1616

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

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

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

0 commit comments

Comments
 (0)