Re: [PATCH 1/6] test-lib: introduce test_commit_bulk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Derrick Stolee <stolee@xxxxxxxxx> writes:

> way to do this loop. The top thing on my mind are the 'eval "echo X"'
> lines. If they start processes, then we can improve the performance.
> If not, then it may not be worth it.

Sigh.  

Do you mean 'echo' run inside 'eval' is one extra process?  In most
modern shells, it is a built-in and you need another process.

Do you mean 'eval' running anything is one extra process?  Because
anything done inside eval must be visible to the shell running it,
e.g.

	var=myvar; eval "$var=val"

would evaluate string 'myvar=val' inside that shell itself and it
must be able to update the value of $myvar, whatever it does must
not add any extra process.

The primary reason why the loop in question uses eval is to allow
the callers to pass $n in single-quote to have it interpolated
lazily.

	message='message $n'
	for n in 1 2 3
	do
		echo "$message"
		eval "echo \"$message\""
	done

Each iteration, the first line gives

	message $n

which is the thing that gets passed to 'echo' in the second line, so
you'll see

	message $n
	message 1
	message $n
	message 2
	message $n
	message 3

as the result.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux