| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT sources DOT redhat DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT sources DOT redhat DOT com> |
| List-Help: | <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-owner AT sources DOT redhat DOT com |
| Delivered-To: | mailing list cygwin AT sources DOT redhat DOT com |
| Message-ID: | <3AFAF02C.545770B1@veritas.com> |
| Date: | Thu, 10 May 2001 12:46:52 -0700 |
| From: | Bob McGowan <rmcgowan AT veritas DOT com> |
| Organization: | VERITAS Software |
| X-Mailer: | Mozilla 4.73 [en] (WinNT; U) |
| X-Accept-Language: | en |
| MIME-Version: | 1.0 |
| To: | JROZYCKI AT ebmail DOT gdeb DOT com |
| CC: | cygwin AT cygwin DOT com |
| Subject: | Re: Question about the 'read' command in bash |
| References: | <85256A48 DOT 006A6FF5 DOT 00 AT ebmail DOT gdeb DOT com> |
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 AT ebmail DOT gdeb DOT 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 AT veritas DOT com -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |