English 中文(简体)
Csh eval statement?
原标题:Csh eval statement?

我试图理解电子日报是如何运作的。 在这里,我看一看我不懂的Im号法规:

    eval `$SOME_DIR/util/dbget.pl 
          VARIABLE1 
          VARIABLE2 
          VARIABLE3 
          VARIABLE4 `

在进行一些研究之后,我最初的想法是,在指挥线的这些指示中,这种说法只是字面上的,即它使用背书,然后......。 我不相信它与这些变量做什么。 以上评论说,“只列出几个参数”,但我不相信这意味着什么。

eval VARIABLE是否开始变数? 看来情况是这样,因为在等值之后,该法典继续使用这些变量,如现在重新采用这些变量(如报表核对等)。

我清楚地看到,这种描述是新的,只是跳入一个大型存放处。 感谢任何帮助。

最佳回答

指示数以两者之间的指挥产出取代。

<代码>eval是指该产出,并按类型执行。

在这种情形下,我假设的是按字母顺序打印一些可变的任务,例如<编码>VARIABLE1=数值1或etenv VARIABLE1值。 在此情况下,在以上<代码>eval之后,您应当有$VARIABLE1,可在后面编码。

如果没有<代码>eval <>/code>,则只读“.pl”文字(我假设是Perl),不会影响sh工艺的环境。 通过使用<条码>eval,你再次准许《规则》修改这种环境。

这意味着,Perl必须知道其产出是用于粉碎的。 在什/巴什,可变转让的辛迪加不同。

ETA More attempted clarification:

如果是:

$SOME_DIR/util/dbget.pl

You get a bunch of variable assignment statements printed to your screen. This is not useful, and has no effect whatsoever on the actual variables in your shell.

如果是:

echo `$SOME_DIR/util/dbget.pl`

你得出了同样的结果,其方式是更加四舍五入:它不是直接在你的屏幕上打印的每升代码,而是印刷成一种投向钟码>/code>的指令的表述,然后是<代码>echo是实际印刷到屏幕上。 这种区别是微妙的,但很重要:背书将控制在外围,使其重新掌握。 一旦炮弹捕获了该产出,它就可以将其储存在变数中,将其输入档案中,或者与它一起做很多其他事情,即《珀尔法典》不必再写,才能处理。 Perl仍然只是印刷。

如果是:

eval `$SOME_DIR/util/dbget.pl`

Then what the shell does is execute the output of the Perl as if it were typed at the prompt. This is very powerful. It s also dangerous, because the surrounding program winds up executing code that the person who wrote that program has never seen. So you have to trust the source of that code (in this case the perl script) not to produce anything damaging (intentinonally or otherwise).

问题回答

<代码>eval 和背书辛奈均在单页上加以解释。

如果您重新进入了含水层系统,则很可能csh 实际上是tcsh,即原始<代码>csh的强化版本。 C-shell。 这些特殊特征在小数和小数中都是相同的。 背书的辛奈援引所谓的“共同替代”。

• 在我的系统上使用剪辑手页(用一些小的 t子来避免标志性的特殊处理):

<<>Command subsitution>

Command substitution is shown by a command enclosed in [backticks]. The output from such a command is normally broken into separate words at blanks, tabs, and newlines, with null words being discarded; this text then replaces the original string. Within double quotes ("), only newlines force new words; blanks and tabs are preserved.

In any case, the single final newline does not force a new word. Note that it is thus possible for a command substitution to yield only part of a word, even if the command outputs a complete line.

而且:

<>

(As in sh(1).) The arguments are read as input to the shell and the resulting command(s) executed in the context of the current shell. This is usually used to execute commands generated as the result of command or variable substi‐ tution, since parsing occurs before these substitutions. See tset(1) for an example of using eval.





相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签