cmd-逗号分隔参数与空格相比? [英] cmd- comma to separate parameters Compared to space?

查看:68
本文介绍了cmd-逗号分隔参数与空格相比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于定界参数,我对这个问题有一些疑问,与空格相比,逗号.

I have some questions on the subject, of commas compared to space, in delimiting parameters.

这是熟悉cmd提示符的C程序员可能会提出一些疑问的问题.

They are questions that C programmers familiar with the cmd prompt, may be able to throw some light on..

我知道这样做的时候

c:\>program a b c

有4个参数 [0] =程序 [1] = a [2] = b [3] =c

根据 hh ntcmds.chm 概念.

Shell概述

; and , are used to separate parameters

; or , command1 parameter1;parameter2  Use to separate command parameters.

我看到 dir a,b 给出的结果与 dir a b

但是

c:\>程序a,b,c 给出参数[0] =程序[1] = a,b,c

c:\>program a,b,c gives parameters [0]=program [1]=a,b,c

是吗?还是全部?Windows命令使用;和 , ?解释是在每个命令的代码中进行的,还是由外壳程序(如空格)进行的解释?

So do some? or all? windows commands use ; and , ? and is that interpretation within the code of each command, or done by the shell like with space?

如果它在每个命令的代码中..我怎么知道该怎么做?我注意到explorer.exe的文档中提到了逗号,例如你可以做 explorer/e,.

And if it is in the code of each command.. how would I know which do it? I notice that documentation of explorer.exe mentions the comma,e.g. you can do explorer /e,.

但是DIR/?没有提及它,但可以使用它.而且典型的c程序根本不使用,作为定界符.因此,外壳不使用逗号定界,而是使用空格的情况是这样.Windows命令会这样做吗?编写它们(全部?)是为了界定使用逗号时shell进一步赋予它们的参数?

but DIR /? does not mention it, but can use it. And a typical c program doesn't take , as a delimiter at all.. So is it the case that the shell doesn't use comma to delimit, it uses space. And windows commands that do, do so 'cos they are (all?) written to delimit the parameters the shell has given them further when commas are used?

推荐答案

Unix和Windows之间有两个区别:

There are two differences here between Unix and Windows:

  • 内部命令(例如 DIR )内置在外壳程序中;他们的命令行语法不必遵循与常规程序相同的规则
  • 在Windows上,程序负责解析其自己的命令行.Shell解析重定向和管道,然后将其余命令行以一个字符串的形式传递给程序
  • Internal commands such as DIR are built into the shell; their command line syntax doesn't have to follow the same rules as for regular programs
  • On Windows, programs are responsible for parsing their own command lines. The shell parses redirects and pipes, then passes the rest of the command line to the program in one string

使用Visual Studio构建的Windows C程序在Microsoft C运行时中使用命令行解析器,类似于典型的Unix Shell解析器,并遵守空格和引号.

Windows C programs built using Visual Studio use the command line parser in the Microsoft C runtime, which is similar to a typical Unix shell parser and obeys spaces and quotation marks.

我从未见过使用; 作为命令行分隔符的C程序.我知道 explorer/e,.的特殊情况,但直到现在我才看过 dir a,b 示例.

I've never seen a C program that uses , or ; as a command line separator. I was aware of the special case for explorer /e,., but I'd never seen the dir a,b example until just now.

这篇关于cmd-逗号分隔参数与空格相比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆