diff --git a/completions/rrh_completion.bash b/completions/rrh_completion.bash index 84f43ee..fd401c2 100644 --- a/completions/rrh_completion.bash +++ b/completions/rrh_completion.bash @@ -16,7 +16,7 @@ __rrh_add() { elif [ "$2" = "-g" ] || [ "$2" = "--group" ]; then groups="$(__rrh_groups)" COMPREPLY=($(compgen -W "$groups" -- "$1")) - elif [ "$4" = "$2" ]; then + else compopt -o filenames COMPREPLY=($(compgen -d -- "$1")) fi diff --git a/list/list_test.go b/list/list_test.go index 08b6101..e9c088a 100644 --- a/list/list_test.go +++ b/list/list_test.go @@ -61,7 +61,7 @@ func TestSimpleResults(t *testing.T) { } }) result = strings.TrimSpace(result) - result = strings.ReplaceAll(result, "\n", ",") + result = strings.Replace(result, "\n", ",", -1) if result != tc.result { t.Errorf("%v: result did not match: wont: %s, got: %s", tc.args, tc.result, result) } diff --git a/path/path_cmd.go b/path/path_cmd.go index 1df466b..b2e97a1 100644 --- a/path/path_cmd.go +++ b/path/path_cmd.go @@ -58,17 +58,18 @@ func (path *PathCommand) perform(db *common.Database) int { return 0 } +func (options *pathOptions) matchEach(id string, arg string) bool { + if options.partialMatch { + return strings.Contains(id, arg) + } + return id == arg +} + func (options *pathOptions) match(id string) bool { for _, arg := range options.args { - if options.partialMatch { - var flag = strings.Contains(id, arg) - if flag { - return true - } - } else { - if id == arg { - return true - } + var bool = options.matchEach(id, arg) + if bool { + return true } } return len(options.args) == 0 diff --git a/path/path_test.go b/path/path_test.go index 032cc07..f15b962 100644 --- a/path/path_test.go +++ b/path/path_test.go @@ -55,7 +55,7 @@ func TestPathCommand(t *testing.T) { }) if tc.status == 0 { output = strings.TrimSpace(output) - output = strings.ReplaceAll(output, "\n", ",") + output = strings.Replace(output, "\n", ",", -1) if output != tc.results { t.Errorf("%v: output did not match: wont: %s, got: %s", tc.args, tc.results, output) }