delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/05/19/09:36:26

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: 1.7.5: Bug with bash read in /etc/profile.d invocation
Date: Wed, 19 May 2010 09:35:09 -0400
Message-ID: <A4AC3816FD34354F878DD1F440F3ABCE02398DBD@CINMLVEM24.e2k.ad.ge.com>
In-Reply-To: <A4AC3816FD34354F878DD1F440F3ABCE02398679@CINMLVEM24.e2k.ad.ge.com>
References: <A4AC3816FD34354F878DD1F440F3ABCE02284615 AT CINMLVEM24 DOT e2k DOT ad DOT ge DOT com> <AANLkTinZUAtd_g3XeSDQdPQJbqL64Cg3RsKXVtNvLH8y AT mail DOT gmail DOT com> <A4AC3816FD34354F878DD1F440F3ABCE02398679 AT CINMLVEM24 DOT e2k DOT ad DOT ge DOT com>
From: "Garber, Dave (GE Infra, Energy, Non-GE)" <dave DOT garber AT ge DOT com>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

OK, I changed my script to have:
	read -p "How are you today? " Ans </dev/stdin
But I now get "bash: /dev/stdin: No such file or directory"

Since profile is redirecting stdin & stdout, wouldn't it make more sense fo=
r profile to redirect stdin and stdout back to normal when sourcing the pro=
file.d scripts?

Thanks,

Dave=20


-----Original Message-----
From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com] On Behalf Of=
 Garber, Dave (GE Infra, Energy, Non-GE)
Sent: Tuesday, May 18, 2010 4:30 PM
To: cygwin AT cygwin DOT com
Subject: RE: 1.7.5: Bug with bash read in /etc/profile.d invocation

Thanks for the info.  This didn't happen in 1.5.25 so something with 1.7.5 =
is different.  I'll go back to my 1.5.25 setup and look at /etc/profile and=
 see what's different.

Dave=20

-----Original Message-----
From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com] On Behalf Of=
 Steven Collins
Sent: Tuesday, May 18, 2010 4:23 PM
To: cygwin AT cygwin DOT com
Subject: Re: 1.7.5: Bug with bash read in /etc/profile.d invocation

Look at /etc/profile where it runs the profile.d scripts.

The scripts are run with standard input redirected to a here document gener=
ated by a find command. That is the source of the "/etc/profile.d/xinit.sh"=
 you're seeing as the answer. The "read"
statement in your script is actually consuming one of the arguments intende=
d to be processed by the "read" in /etc/profile.

Because the scripts are sourced by the current shell your "#!" line has no =
affect ("-x" isn't getting set.)

In other words, the shell is doing exactly what it has been told to do. Don=
't use a read in your profile.d scripts unless you make sure to reroute sta=
ndard input back to the terminal.

On Thu, May 13, 2010 at 07:16, Garber, Dave (GE Infra, Energy, Non-GE) <> w=
rote:
> #!/usr/bin/bash -x
> =A0 =A0 =A0 =A0echo In p.sh
> =A0 =A0 =A0 =A0read -p "How are you today? " Ans
> =A0 =A0 =A0 =A0echo Ans is $Ans

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019