Skip to content

Commit 067e867

Browse files
committed
Fix error on queries starting with dash
Fixes #118
1 parent 85f863f commit 067e867

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

functions/__z.fish

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function __z -d "Jump to a recent directory."
1414
function __z_legacy_escape_regex
1515
# taken from escape_string_pcre2 in fish
1616
# used to provide compatibility with fish 2
17-
for c in (string split '' $argv)
17+
for c in (string split -- '' $argv)
1818
if contains $c (string split '' '.^$*+()?[{}\\|-]')
1919
printf \\
2020
end
@@ -123,15 +123,15 @@ function __z -d "Jump to a recent directory."
123123
for arg in $argv
124124
set -l escaped $arg
125125
if string escape --style=regex '' >/dev/null 2>&1 # use builtin escape if available
126-
set escaped (string escape --style=regex $escaped)
126+
set escaped (string escape --style=regex -- $escaped)
127127
else
128128
set escaped (__z_legacy_escape_regex $escaped)
129129
end
130130
# Need to escape twice, see https://www.math.utah.edu/docs/info/gawk_5.html#SEC32
131-
set escaped (string replace --all \\ \\\\ $escaped)
131+
set escaped (string replace --all -- \\ \\\\ $escaped)
132132
set qs $qs $escaped
133133
end
134-
set -l q (string join '.*' $qs)
134+
set -l q (string join -- '.*' $qs)
135135

136136
if set -q _flag_list
137137
# Handle list separately as it can print common path information to stderr

0 commit comments

Comments
 (0)