From c81971d1d8838178155cf02aa0a26b157016a742 Mon Sep 17 00:00:00 2001 From: Ivan Povalyukhin Date: Sat, 11 Apr 2015 13:45:58 -0700 Subject: [PATCH 1/2] preserve attributes of $CONFIG_FILE on backup --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 26c62c24..7c3ff111 100755 --- a/install.sh +++ b/install.sh @@ -11,7 +11,7 @@ case $OSTYPE in esac test -w $HOME/$CONFIG_FILE && - cp $HOME/$CONFIG_FILE $HOME/$CONFIG_FILE.bak && + cp -a $HOME/$CONFIG_FILE $HOME/$CONFIG_FILE.bak && echo "Your original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak" cp $HOME/.bash_it/template/bash_profile.template.bash $HOME/$CONFIG_FILE From f4205609862258e875859707129d7c46add88ee7 Mon Sep 17 00:00:00 2001 From: Ivan Povalyukhin Date: Sat, 11 Apr 2015 13:50:39 -0700 Subject: [PATCH 2/2] make buf() to respect file attributes on file backup --- plugins/available/base.plugin.bash | 2 +- test/plugins/base.plugin.bats | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index 8c8a2c50..837d7536 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -213,5 +213,5 @@ function buf () group 'base' local filename=$1 local filetime=$(date +%Y%m%d_%H%M%S) - cp "${filename}" "${filename}_${filetime}" + cp -a "${filename}" "${filename}_${filetime}" } diff --git a/test/plugins/base.plugin.bats b/test/plugins/base.plugin.bats index 9bc9f0e6..1d940984 100755 --- a/test/plugins/base.plugin.bats +++ b/test/plugins/base.plugin.bats @@ -34,3 +34,11 @@ load ../../plugins/available/base.plugin assert_success [[ $output == l? ]] } + +@test 'plugins base: buf()' { + mkdir -p $BASH_IT_ROOT + declare -r file="${BASH_IT_ROOT}/file" + touch $file + run buf $file + [[ -e ${file}_$(date +%Y%m%d_%H%M%S) ]] +}