问题
I have the following function:
function is_file
set file $argv[1]
if test ‐f $file
return 0
else
return 1
end
end
However when calling it:
is_file ~/.vimrc
I get:
test: Missing argument at index 2
What am I missing?
回答1:
The problem is the hyphen in the line
if test ‐f $file
It is encoded as a Unicode hyphen U+2010, but it should be the ASCII hyphen-minus (0x2D) which is Unicode character U+002D. If I delete the hyphen and retype it myself, it works fine for me.
By the way, this function could be written more concisely:
function is_file
test -f $argv[1]
end
来源:https://stackoverflow.com/questions/23483919/fish-shell-test-missing-argument-at-index-2