File tree Expand file tree Collapse file tree 2 files changed +73
-6
lines changed
share/github-backup-utils Expand file tree Collapse file tree 2 files changed +73
-6
lines changed Original file line number Diff line number Diff line change 7
7
set -o pipefail
8
8
9
9
# set the variable from the first argument and remove any leading dashes
10
- rsync_command=$( echo " $1 " | sed -E ' s/^-+// ' )
10
+ rsync_command=$1
11
11
12
- # check if the passed rsync command is supported by the current version of rsync
13
- if rsync -h | grep -E " \B-+($rsync_command )\b" > /dev/null 2>&1 ; then
14
- echo " true"
12
+ # extract dashes if present into variable
13
+ leading_dashes=$( echo " $rsync_command " | grep -oE " ^-+" )
14
+
15
+ # this normalizes the passed command by removing any leading dashes
16
+ normalized_command=$( echo " $rsync_command " | sed -E " s/^-+//" )
17
+
18
+ # this checks the rsync command and returns the found command if it is valid
19
+ found_command=$( rsync -h | grep -oE " \B-+($normalized_command )\b" | head -n " 1" )
20
+
21
+ # this is the normalized found command
22
+ normalized_found_command=$( echo " $found_command " | sed -E " s/^-+//" )
23
+
24
+ # # Check if $leading_dashes is either - or --
25
+ if [ " $leading_dashes " == " -" ]; then
26
+ # check if the passed rsync command is valid and supported or if the normalized command is valid and supported
27
+ if [ " $rsync_command " == " $found_command " ]; then
28
+ echo " true"
29
+ else
30
+ echo " false"
31
+ fi
32
+ elif [ " $leading_dashes " == " --" ]; then
33
+ # check if the passed rsync command is valid and supported or if the normalized command is valid and supported
34
+ if [ " $rsync_command " == " $found_command " ]; then
35
+ echo " true"
36
+ else
37
+ echo " false"
38
+ fi
15
39
else
16
- echo " false"
17
- fi
40
+ # check if the passed rsync command is valid and supported or if the normalized command is valid and supported
41
+ if [ " $rsync_command " == " $normalized_found_command " ]; then
42
+ echo " true"
43
+ else
44
+ echo " false"
45
+ fi
46
+ fi
47
+
Original file line number Diff line number Diff line change @@ -17,6 +17,18 @@ begin_test "Testing ghe-rsync-feature-checker for known supported command --help
17
17
)
18
18
end_test
19
19
20
+ <<< <<< < Updated upstream
21
+ =======
22
+ begin_test " Testing ghe-rsync-feature-checker for known supported command -help"
23
+ (
24
+ set -e
25
+
26
+ # Test ghe-rsync-feature-checker command
27
+ ghe-rsync-feature-checker -help | grep -q " false"
28
+ )
29
+ end_test
30
+
31
+ >>>>>>> Stashed changes
20
32
begin_test " Testing ghe-rsync-feature-checker with known supported command help"
21
33
(
22
34
set -e
@@ -38,6 +50,19 @@ begin_test "Testing ghe-rsync-feature-checker with known unsupported command --n
38
50
)
39
51
end_test
40
52
53
+ <<< <<< < Updated upstream
54
+ =======
55
+ begin_test " Testing ghe-rsync-feature-checker with known unsupported command -not-an-actual-feature"
56
+ (
57
+ set -e
58
+
59
+ # Test ghe-rsync-feature-checker command
60
+ ghe-rsync-feature-checker -not-an-actual-feature | grep -q " false"
61
+
62
+ )
63
+ end_test
64
+
65
+ >>>>>>> Stashed changes
41
66
begin_test " Testing ghe-rsync-feature-checker with known unsupported command not-an-actual-feature"
42
67
(
43
68
set -e
@@ -98,6 +123,18 @@ begin_test "Testing ghe-rsync-feature-checker with known supported command --ver
98
123
)
99
124
end_test
100
125
126
+ <<< <<< < Updated upstream
127
+ =======
128
+ begin_test " Testing ghe-rsync-feature-checker with known supported command -verbose"
129
+ (
130
+ set -e
131
+
132
+ # Test ghe-rsync-feature-checker command
133
+ ghe-rsync-feature-checker -verbose | grep -q " false"
134
+ )
135
+ end_test
136
+
137
+ >>>>>>> Stashed changes
101
138
begin_test " Testing ghe-rsync-feature-checker with known supported command verbose"
102
139
(
103
140
set -e
You can’t perform that action at this time.
0 commit comments