zsh: no matches found: 错误解决 setopt no_nomatch

痛定思痛。 2022-10-06 12:47 428阅读 0赞

文章目录

    • Intro
    • 解决方式
      • 当前shell修改配置
      • 配置永久生效
    • WHY
      • no_match 选项

Intro

我在zsh上执行一些命令(我在使用JDK自带的wsimport从WSDL生成Java客户端代码)的时候,遇到一些问题。

命令内容及功能不重要,问题的原因都是因为shell兼容性的相关配置

以下为命令执行内容:

  1. wsimport http://www.wuyujin.com:8000/webservice-server-java/index?wsdl
  2. zsh: no matches found: http://www.wuyujin.com:8000/webservice-server-java/index?wsdl
  3. leung@wuyujin wsimmportoutput %
  4. leung@wuyujin wsimmportoutput % setopt no_nomatch
  5. leung@wuyujin wsimmportoutput %
  6. leung@wuyujin wsimmportoutput % wsimport http://www.wuyujin.com:8000/webservice-server-java/index?wsdl
  7. 正在解析 WSDL...
  8. 正在生成代码...
  9. 正在编译代码...
  10. leung@wuyujin wsimmportoutput %

现象是同样的命令,只有在zsh才会出现,而使用bashsh执行时,没有问题。

在这里插入图片描述

解决方式

当前shell修改配置

对当前zsh执行一次setopt no_nomatch (效果见上图)

配置永久生效

该设置可以被写入当前用户的zsh配置文件,以便永久生效。

vi ~/.zshrc

编辑,新增要执行的配置行即可

setopt no_nomatch

重新执行该配置脚本

source ~/.zshrc

在这里插入图片描述

WHY

刚才做了什么?
为什么之前会报错?
做了刚才的操作之后为什么不报错?

What are Shell Options

在这里插入图片描述
只关注部分:

  1. Shell options are preferences for the shells behavior.
  2. Shell options shell表现(行为)的首选项(参数配置)
  3. zsh has a lot of shell options. Many of these options serve the purpose of enabling (or disabling) compatibility with other shells.
  4. zsh有很多的shell选项。其中很多选项的目的是:启用或禁用与其他shell的兼容性。
  5. There are also many options which are specific to zsh.
  6. 也有很多shell选项,是zsh独有的。
  7. You can set an option with the setopt command.
  8. 你可以通过 setopt 命令设置选项值。
  9. For compatibility with other shells the setopt command and set -o have the same effect (set an option by name).
  10. 为了与其他 shell 兼容而使用 setopt 命令,等效于使用 set -o (通过选项名去设置值)

点击链接 a lot of shell options

在这里插入图片描述再次获取信息:

  • 选项通过名称来引用/参考。
  • 名称不区分大小写,会忽略下划线(如:allexport等效于A_lleXP_port)
  • 在选项名前加前缀 no 可以颠倒该选项的意义。(setopt No_Beep等效于unsetopt beep)

no_match 选项

no_nomatch
在这里插入图片描述
nomatch
在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,428人围观)

还没有评论,来说两句吧...

相关阅读