fish-shell/share/functions/contains_seq.fish
ridiculousfish f2b5292bcb Squashed commit of the following:
commit 33358874f1c275d8b08186e29f24a7889d2b5224
Author: maxfl <gmaxfl@gmail.com>
Date:   Thu Jun 14 11:01:13 2012 +0400

    revert fish_pager

commit cee1bc8a66ec3adc9573b76e1aca3131cd32db83
Author: maxfl <gmaxfl@gmail.com>
Date:   Thu Jun 14 10:57:41 2012 +0400

    revert fish_pager.cpp

commit 27f3bd39dd9903009503d20a59a9e2ba84add07a
Author: maxfl <gmaxfl@gmail.com>
Date:   Wed Jun 13 17:35:20 2012 +0400

    __fish_complete_command now can understand '--arg=option' tokens
    latexmk completion is updated

commit 97b53a4b53de9389675783f3e90f58215d936356
Author: maxfl <gmaxfl@gmail.com>
Date:   Wed Jun 13 16:46:47 2012 +0400

    . completion

commit d5b63b9963b0a02a71f564e7392171c5eab005cd
Author: maxfl <gmaxfl@gmail.com>
Date:   Wed Jun 13 16:46:13 2012 +0400

    a lot of new completions

commit ceab87d99425124aa010c64ed062e27202b850d2
Author: Maxim Gonchar <gonchar@myhost.localdomain>
Date:   Tue Jun 12 20:19:31 2012 +0400

    A lot of new completions.
    Some small updates and fixes of old functions and completions.

commit 950aecd570b51e1b9dc444cc651b282a220e8d94
Author: Maxim Gonchar <gonchar@myhost.localdomain>
Date:   Tue Jun 12 20:03:44 2012 +0400

    step-coloring initial
    set_color correction
2012-06-15 17:30:33 -07:00

50 lines
858 B
Fish

function contains_seq --description 'Return true if array contains a sequence'
set -l printnext
switch $argv[1]
case --printnext
set printnext[1] 1
set -e argv[1]
end
set -l pattern
set -l string
set -l dest pattern
for i in $argv
if test "$i" = --
set dest string
continue
end
set $dest $$dest $i
end
set -l nomatch 1
set -l i 1
for s in $string
if set -q printnext[2]
echo $s
return 0
end
echo a $nomatch
if test "$s" = "$pattern[$i]"
echo b $nomatch
echo c $nomatch[1]
set -e nomatch[1]
set i (expr $i + 1)
if not set -q pattern[$i]
if set -q printnext[1]
set printnext[2] 1
continue
end
return 0
end
else
if not set -q nomatch[1]
set nomatch 1
set i 1
end
end
end
if set -q printnext[1]
echo ''
end
set -q printnext[2]
end