Re: Late variable evaluation
- From: Lew Pitcher <lpitcher@xxxxxxxxxxxx>
- Date: Mon, 22 May 2006 20:25:49 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
engeler@xxxxxxxxx wrote:
I thought the process "echo $t" is started anew on each iteration of
the while-loop, and therefore the variable $t read again. $t belongs to
the shell, not to the process?
Given your original statement of the shellcode
t=foothen your understanding is incorrect.
( while true; do echo $t; sleep 1; done ) &
The code fragment
( while true; do echo $t; sleep 1; done )
will be launched in a subshell, and once that happens, any changes to
variables in the parent shell will not be passed on to the code fragment.
When this fragment is launched, $t has the value of 'foo', and so the subshell
inherits that value for /it's/ version of $t. If you later change the parent
shell's value for $t, the change will not (and cannot) be propogated to the
subshell running the code fragment.
- --
Lew Pitcher
Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFEclaNagVFX4UWr64RAnKFAJ9T+qSx3K+u7dOm9MJ8zTCd2DM29ACfYz6L
WBR5tEgZZ3GOxMdWDH8UijI=
=hEio
-----END PGP SIGNATURE-----
.
- References:
- Late variable evaluation
- From: engeler
- Re: Late variable evaluation
- From: Bill Marcum
- Re: Late variable evaluation
- From: engeler
- Late variable evaluation
- Prev by Date: Re: File variables comparision with shell script
- Next by Date: adding a column in a file using awk
- Previous by thread: Re: Late variable evaluation
- Next by thread: File variables comparision with shell script
- Index(es):
Relevant Pages
|
|