mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
completions: make: respect line continuations in recipes
Without this, a recipe containing a trailing backslash followed by a line not
beginning with tab (like any non-continued recipe lines would) would result in
the continuation showing up in completions.
Whenever a line ends in a backslash, consider the next line invalid as a target.
Regex explanation:
^([^#]*[^#\\])? -- optional prefix not containing comment character and not
ending in backslash
(\\\\)*\\$ -- 2n+1 backslashes at end of line (handles escaped backslashes)
(cherry picked from commit fff320b56b
)
This commit is contained in:
parent
f82f92df13
commit
0b1aa0b12e
1 changed files with 6 additions and 2 deletions
|
@ -12,9 +12,13 @@ function __fish_print_make_targets --argument-names directory file
|
|||
if make --version 2>/dev/null | string match -q 'GNU*'
|
||||
# https://stackoverflow.com/a/26339924
|
||||
make $makeflags -pRrq : 2>/dev/null |
|
||||
awk -F: '/^# Files/,/^# Finished Make data base/ {
|
||||
awk -F: -v 'bs_regex=\\\\\\\\' '/^# Files/,/^# Finished Make data base/ {
|
||||
if ($1 == "# Not a target") skip = 1;
|
||||
if ($1 !~ "^[#.\t]") { if (!skip) print $1; skip=0 }
|
||||
if ($1 !~ "^[#.\t]" && !is_continuation ) {
|
||||
if (!skip) print $1;
|
||||
skip = 0
|
||||
}
|
||||
is_continuation = $0 ~ "^([^#]*[^#" bs_regex "])?(" bs_regex bs_regex ")*" bs_regex "$";
|
||||
}' 2>/dev/null
|
||||
else
|
||||
# BSD make
|
||||
|
|
Loading…
Reference in a new issue