has_prefix fish util
This commit is contained in:
parent
8c396b7101
commit
200edc9c96
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env fish
|
||||
|
||||
function has_prefix
|
||||
set -f input_str $argv[2]
|
||||
set -f match $argv[1]
|
||||
if test -z $input_str; or test -z $match
|
||||
log -c red "input[$input_str]/match[$match] empty"
|
||||
return 1
|
||||
end
|
||||
set -f m_len (string length $match)
|
||||
set -f input_len (string length $input_str)
|
||||
if test $m_len -gt $input_len
|
||||
return 1
|
||||
end
|
||||
set -f cut_input (string sub -l $m_len $input_str)
|
||||
return (test "$cut_input" = "$match")
|
||||
end
|
Loading…
Reference in New Issue