Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aliyun alidns AddDomainRecord 命令 value不支持-开头 #537

Closed
walkerxk opened this issue Nov 7, 2022 · 5 comments
Closed

aliyun alidns AddDomainRecord 命令 value不支持-开头 #537

walkerxk opened this issue Nov 7, 2022 · 5 comments

Comments

@walkerxk
Copy link

walkerxk commented Nov 7, 2022

  • 执行命令:
    aliyun alidns AddDomainRecord --DomainName makemusic-asia.com --RR test --Type txt --Value '-a'
  • 输出:
    ERROR: parse failed unknown flag -a
    0@09:42:53#walkerxk@ecs/> aliyun alidns AddDomainRecord --DomainName makemusic-asia.com --RR test --Type txt --Value 'a'
    {
    "RecordId": "794716613104842752",
    "RequestId": "4CE364B2-EF06-5A95-9B6F-7BB365B12551"
    }
    0@09:43:06#walkerxk@ecs/> aliyun alidns AddDomainRecord --DomainName makemusic-asia.com --RR test --Type txt --Value '-a'
    ERROR: parse failed unknown flag -a
    0@09:43:08#walkerxk@ecs/> aliyun alidns AddDomainRecord --DomainName makemusic-asia.com --RR test --Type txt --Value -- '-a'
    ERROR: parse failed not support '--' in command line
    0@09:43:34#walkerxk@ecs/>
    value以-开头就报错
@walkerxk
Copy link
Author

walkerxk commented Nov 7, 2022

使用这种方式可以,但是空格的方式最好也支持下。
aliyun alidns AddDomainRecord --DomainName=makemusic-asia.com --RR=test --Type=txt --Value=-a

@JacksonTian
Copy link
Contributor

@walkerxk
Copy link
Author

https://github.com/aliyun/aliyun-cli#special-argument 参考下这个。

是的,我上面写了,用=就行了,但是命令行传参用等号还是有点怪,最好能支持下空格的方式。

@JacksonTian
Copy link
Contributor

横杠被用作了 arguments 解析了。参数值与之冲突了。

@walkerxk
Copy link
Author

walkerxk commented Nov 14, 2022

横杠被用作了 arguments 解析了。参数值与之冲突了。
这个我知道,但是linux下的命令,一般是能自动识别的。

用getopt-example.bash做个例子吧
./getopt-example.bash -a par1 'another arg' --c-long 'wow!' -cmore -b " very long "
Option a
Option c, no argument
Option c, argument 'more'
Option b, argument ' very long '
Remaining arguments:
--> 'par1'
--> 'another arg'
--> 'wow!*'

比如某个option后面必须加argument,那么后面的字���串不管是什么,都当成argument,不能当成option,比如下面的find -name -a
然后如果遇到一些情况没法区分是文件名还是option的时候,就用--来指定后面部分都是文件名或者argument,不是option
https://linux.die.net/man/1/bash

A -- signals the end of options and disables further option processing. Any arguments after the -- are treated as filenames and arguments. An argument of - is equivalent to --.
44@11:27:42#xiakai1@kec/test.d> touch -- -a
44@11:27:45#xiakai1@kec/test.d> ls -l
total 0
-rw-rw-r-- 1 xiakai1 xiakai1 0 Nov 14 11:27 -a
44@11:27:48#xiakai1@kec/test.d> find -name -a
./-a
44@11:28:00#xiakai1@kec/test.d> rm -- -a
44@11:28:04#xiakai1@kec/test.d> ls -l
total 0
44@11:28:07#xiakai1@kec/test.d>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants