Fish shell: test: Missing argument at index 2

佐手、 提交于 2020-01-15 09:48:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!