* [Summary] Bourne shell question
@ 1999-05-24 11:44 C.Ruhnke
0 siblings, 0 replies; only message in thread
From: C.Ruhnke @ 1999-05-24 11:44 UTC (permalink / raw)
To: tru64-unix-managers
Thanks for quick responses from
Steve VanDevender
Kurt Carlson
Kevin Partin
Richard Sharpe
and Ian Mortimer
The kewpie dolls go to Steve and Ian who noted that "read" is a shell
internal for Bourne shell and is executed as a sub-shell. Thus the
variable mydir gets set in the sub-shell and never exists in the calling
shell.
All of the above recommended using mydir=`pwd` instead.
[Original post]
>
> I am NOT a shell expert (yet!), so I may just be misunderstanding this...
>
> I expect the following script to set the variable mydir to the current
> working directory. If I run it under the Korn shell, it does what
> I expect. If I run it under Bourne shell, then mydir echoes as empty.
>
>
> #!/usr/bin/ksh
> #
> # This does not seem to work using sh but does for ksh
> #
> pwd | read mydir
> echo $mydir
>
> The man pages for "read" don't indicate any variation due to shell.
> Is this the expected function of "sh" and "ksh"?
--CHRis
-
=============================================================================
Chris H. Ruhnke Phone: (314)233-7314
IBM Global Services M/S S306-6340 FAX : (314)234-2262
325 J.S. McDonnell Blvd Email: Ruhnke@US.ibm.com
Hazelwood, MO 63042
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-05-24 11:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-05-24 11:44 [Summary] Bourne shell question C.Ruhnke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox