Browse Source

Fix cp arguments, add double quotes

master
Riyyi 6 years ago
parent
commit
321fd2d044
  1. 10
      dotfiles.sh

10
dotfiles.sh

@ -69,18 +69,18 @@ files() {
add() { add() {
[ "$1" = "" ] && return 1 [ "$1" = "" ] && return 1
FILE="$(readlink -f $(dirname $1))/$(basename $1)" FILE="$(readlink -f "$(dirname "$1")")/$(basename "$1")"
FILE_CUT_HOME="$(echo "$FILE" \ FILE_CUT_HOME="$(echo "$FILE" \
| awk -v m="^$HOME/" '$0 ~ m { print substr($0, length(m)) }')" | awk -v m="^$HOME/" '$0 ~ m { print substr($0, length(m)) }')"
# /home/<user>/ # /home/<user>/
if [ -n "$FILE_CUT_HOME" ]; then if [ -n "$FILE_CUT_HOME" ]; then
mkdir -p "$(pwd)/$(dirname "$FILE_CUT_HOME")" mkdir -p "$(pwd)/$(dirname "$FILE_CUT_HOME")"
cp -Ppr "$FILE" "$(pwd)/$FILE_CUT_HOME" cp -a "$FILE" "$(pwd)/$FILE_CUT_HOME"
# / # /
else else
mkdir -p "$(pwd)/$(dirname "$FILE")" mkdir -p "$(pwd)/$(dirname "$FILE")"
cp -PPr "$FILE" "$(pwd)/$FILE" cp -a "$FILE" "$(pwd)/$FILE"
fi fi
} }
@ -94,7 +94,7 @@ pull_push() {
fr=$(readlink -f "$f") fr=$(readlink -f "$f")
# The filepath starts with '/boot/', '/etc/', '/usr/share/' # The filepath starts with '/boot/', '/etc/', '/usr/share/'
if [ -n "$(echo "$fr" | sed -nr 's/^(\/(boot|etc|usr\/share)\/).*$/\1/p')" ]; then if [ -n "$(echo "$fr" | sed -nE 's/^(\/(boot|etc|usr\/share)\/).*$/\1/p')" ]; then
if [ "$1" = "pull" ]; then if [ "$1" = "pull" ]; then
sudo cp "$fr" "$(pwd)/$fr" sudo cp "$fr" "$(pwd)/$fr"
elif [ "$1" = "push" ]; then elif [ "$1" = "push" ]; then
@ -144,7 +144,7 @@ packages() {
AUR_LIST="$(grep -vx "$CORE_LIST" < $PACKAGE_FILE)" AUR_LIST="$(grep -vx "$CORE_LIST" < $PACKAGE_FILE)"
# Install AUR packages # Install AUR packages
$AUR_HELPER -S --needed --noconfirm $AUR_LIST "$AUR_HELPER" -S --needed --noconfirm $AUR_LIST
fi fi
fi fi
} }

Loading…
Cancel
Save