Skip to content

Commit

Permalink
Simplify install.sh (take 2) (#16829)
Browse files Browse the repository at this point in the history
*  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
  • Loading branch information
albap authored and tkelman committed Jun 9, 2016
1 parent 47386ea commit 6de9e97
Showing 1 changed file with 6 additions and 5 deletions.
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

0 comments on commit 6de9e97

Please sign in to comment.