Re: Executing a command in sub-shell
From: udayan (udayan_singh_at_lko.tcs.co.in)
Date: 02/12/04
- Next message: Nils Petter Vaskinn: "Re: Using Fifos [was : Piping to Input of Running App]"
- Previous message: udayan: "Re: Executing a command in sub-shell"
- In reply to: Kevin Rodgers: "Re: Executing a command in sub-shell"
- Next in thread: Chris F.A. Johnson: "Re: Executing a command in sub-shell"
- Reply: Chris F.A. Johnson: "Re: Executing a command in sub-shell"
- Reply: Kevin Rodgers: "Re: Executing a command in sub-shell"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Feb 2004 01:16:09 -0800
Kevin Rodgers <ihs_4664@yahoo.com> wrote in message news:<402ACB9B.4030908@yahoo.com>...
> udayan wrote:
> > Kevin Rodgers <ihs_4664@yahoo.com> wrote in message
> news:<40292020.7050703@yahoo.com>...
> > Apart from above mentioned, I am not able to understand the behaviour
> > mentioned below -
> >
> > ###########Code -
> > #!/bin/sh
> >
> > MY_NAME="UDAYAN"
> > cleartool setview usingh_dev_view <<- _setview
> > echo "my view is usingh_dev_view "
> > cleartool pwv
> > cleartool setact Tools <<- _setact
> > val1=0
> > echo "val1 = ${val1}"
> > echo ${MY_NAME}
> > _setact
> > cleartool pwv
> > _setview
> > echo "val1 = ${val1}"
> >
> > #############script ends here . Now the output follows
> > my view is usingh_dev_view
> > Working directory view: ** NONE **
> > Set view: usingh_dev_view
> > Set activity "Tools" in view "usingh_dev_view".
> > Working directory view: ** NONE **
> > Set view: usingh_dev_view
> > val1 =
> >
> >
> > ########### here the value of val1 is not printed ?? why??
>
> It's not clear at all, because there are 2 `echo val1` commands in your
> script and only 1 line of output, and apparently the nested subshells'
> eoutput is interleaved (perhaps because some commands are writing to
> standard output and some to standard error).
Well I'll again give the code with slight modifications - This is
exactly what i m getting -
###########Code starts here -
#!/bin/sh
MY_NAME="UDAYAN"
cleartool setview usingh_dev_view <<- _setview
echo "my view is usingh_dev_view "
cleartool pwv
echo "${MY_NAME}"
cleartool setact Tools <<- _setact
echo "hi"
cleartool pwv
_setact
_setview
################Code ends here , and now the output
my view is usingh_dev_view
Working directory view: ** NONE **
Set view: usingh_dev_view
UDAYAN
Set activity "Tools" in view "usingh_dev_view".
###################Output ends here.
See the lines -
'echo "hi"'
cleartool pwv
- in the other second sub-shell. They are never printed out on the
screen!!
This was the thing which i m not able to understand.
>
> In any case, the first reference to ${val1} occurs within the here
> document, which is expanded by the shell where it has not been set.
Nope i dont agree.. If you look on the previous piece of code, there
the val1 is echoed in the same second sub-shell.
> To
> expand it dynamically in the subshell, it needs to be quoted in the here
> document:
>
> echo "val1 = \${val1}"
>
> (And since it's 2 levels deep, it may need to be quoted twice. :-)
Might be if i had done something like this then it would have come up.
>
> The second occurrence occurs in the shell script, after the subshell
> where it was set has exited. Just as a child process can't effect the
> environment of its parent process, a subshell can't set a variable in
> its parent shell, so you're out of luck there.
this brings a new topic.. how can i export my variables to the parent
shell from the sub-shell?
tia,
us
- Next message: Nils Petter Vaskinn: "Re: Using Fifos [was : Piping to Input of Running App]"
- Previous message: udayan: "Re: Executing a command in sub-shell"
- In reply to: Kevin Rodgers: "Re: Executing a command in sub-shell"
- Next in thread: Chris F.A. Johnson: "Re: Executing a command in sub-shell"
- Reply: Chris F.A. Johnson: "Re: Executing a command in sub-shell"
- Reply: Kevin Rodgers: "Re: Executing a command in sub-shell"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|