delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/11/19/16:15:32

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Wed, 19 Nov 2003 16:14:58 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Wirawan Purwanto <wirawan AT camelot DOT physics DOT wm DOT edu>
cc: cygwin AT cygwin DOT com
Subject: Re: Problem with noninteractive bash initialization
In-Reply-To: <Pine.LNX.4.50.0311191531400.3163-100000@wirawan0.lan>
Message-ID: <Pine.GSO.4.56.0311191610560.12731@slinky.cs.nyu.edu>
References: <Pine DOT LNX DOT 4 DOT 50 DOT 0311191531400 DOT 3163-100000 AT wirawan0 DOT lan>
Importance: Normal
MIME-Version: 1.0

On Wed, 19 Nov 2003, Wirawan Purwanto wrote:

> Hi,
>
> How should a noninteractive bash begin (i.e. for executing a script)?
> Should bash read init files like ~/.bashrc, ~/.bash_profile, or
> /etc/profile? According to bash documentation on
>
>   http://www.gnu.org/manual/bash-2.05a/html_mono/bashref.html#SEC62 ,
>
> NO initialization files would be read. But cygwin's bash (version
> 2.05b.0(1)-release) DOES reads and executes ~/.bashrc BEFORE executing the
> actual script itself. Why is this? Is this not a deviation from the
> prescribed behavior, or what?
>
> <---- long explanation
>
> To find out whether the .bashrc is executed, simply create a trivial
> script "xyz". For simplicity let's assume it contains only an echo
> command:
>
>         #!/bin/bash
>         echo "Hellow"
>
> Then execute:
>
>         $ bash -x xyz
>
> According to BASH standard, it should result in the following printout:
>
>         + echo 'Hellow'
>         Hellow
>
> This is what happens on my linux box (a Mandrake 9.1, with bash version
> 2.05b.0(1)-release also). But in my cygwin window [under Windows 2000], it
> spits out lots of initialization commands from ~/.bashrc before finally
> executing the echo "Hellow" statement.
>
> end long explanation ---->
>
> Can somebody explain what's wrong with this?
>
> Wirawan

Don't know, WFM:

$ echo '#!/bin/bash
echo "Hellow"' > xyz
$ bash -x xyz
+ echo Hellow
Hellow
$ bash --version
GNU bash, version 2.05b.0(1)-release (i686-pc-cygwin)
Copyright (C) 2002 Free Software Foundation, Inc.
$

BTW, the #! line is redundant if you invoke the script this way -- bash
(the one you invoked on the command line) simply interprets the commands
in it, and #! is ignored.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

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

- Raw text -


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