18 lines
474 B
Fish
Executable File
18 lines
474 B
Fish
Executable File
#!/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
|