This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Question about the 'read' command in bash


ksh is not bash (nor is it pdksh).  ksh manages to do several things in the
current shell, while bash and pdksh handle it in a sub-process.  Variables in a
sub-process cannot affect the environment of the parent.

The solution is to use substitution:

  op_sys=$(uname | cut -c1-4)

and use the value.  I'd suggest that this is the more portable and probably the
preferred way of doing this.

JROZYCKI@ebmail.gdeb.com wrote:
> 
> I have a bash shell script with the following lines of code:
> 
> #!/bin/bash
> uname | cut -c1-4 | read op_sys
> echo $op_sys
> 
> This works fine at work using SGI IRIX and ksh, but under cygwin and bash
> at home, op_sys does not get set - null is echoed.. what do I need to do
> differently?
> 
> thanks,
> Jeff
> 
> --
> Want to unsubscribe from this list?
> Check out: http://cygwin.com/ml/#unsubscribe-simple

-- 
Bob McGowan
Staff Development Engineer
VERITAS Software
rmcgowan@veritas.com

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]