From acf3206297912cc2432f93db77d8fdabe33af5fd Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Sat, 30 Aug 2014 15:44:48 +0400 Subject: [PATCH] bak plugin: fixed directories handling --- plugins/bak/bak.load | 4 ++-- plugins/bak/tests/test_bak.fish | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/bak/bak.load b/plugins/bak/bak.load index 671a737..fd77967 100644 --- a/plugins/bak/bak.load +++ b/plugins/bak/bak.load @@ -16,7 +16,7 @@ end function __bak_name # trim / for directories - set file (echo $argv[1] | sed 's/\/$//') + set file (echo $argv[1] | sed 's/\/*$//') echo "$file."(date +'%Y%m%d_%H%M%S')".bak" end @@ -30,7 +30,7 @@ function __bak end end -set -g __bak_re '(.*)\.[0-9]{8,8}_[0-9]{6,6}\.bak$' +set -g __bak_re '(.*)\.[0-9]{8,8}_[0-9]{6,6}\.bak\/*$' function __is_bak set file $argv[1] diff --git a/plugins/bak/tests/test_bak.fish b/plugins/bak/tests/test_bak.fish index 6b5b2a9..f6a294f 100755 --- a/plugins/bak/tests/test_bak.fish +++ b/plugins/bak/tests/test_bak.fish @@ -72,6 +72,14 @@ function suite_bak assert_equal (echo -e 'a' (__bak_name a) | sort) (ls | sort) end + function test_uncp_dir_single + mkdir a + cpbak a/ + rmdir a + uncpbak (ls -p) + assert_equal (echo -e 'a/' (__bak_name a)'/' | sort) (ls -p | sort) + end + function test_cp_multiple set files (seq 4) touch $files