Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: =?ISO-8859-15?Q?Ren=E9_Berber?= Subject: Re: /etc/profile always does a "cd $HOME" Date: Sun, 22 May 2005 16:18:47 -0500 Lines: 80 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) In-Reply-To: X-IsSubscribed: yes Sven Köhler wrote: > i'd like to use cygwin from a normal windows-app. The problem is, that i > need a login-shell, so that all environment-vars are properly set. The > problem: bash -li always changes the current workdir! That's not a problem, it's a feature. > IMHO, executing "bash -li" shouldn't change the workdir. Wrong! > No other system i know does that. Not true, "bash -li" works the same in any system that runs bash. You are probably thinking of running "bash" without the parameter... that execution doesn't change the current location. In fact, if you login into any system using any shell you login into your home dir. That's the idea that the -l or --login parameter make explicit. > Script may rely on that behaviour. > > /etc/profile contains the like > cd "$HOME" > > That line cannot easily be removed. Starting the Cygwin-Link installed > by the setup wouldn't cd to ~ anymore. This behaviours is liked by most > users i guess (including my own). > > Any suggestions, how the situation could be improved? Yep, read the bash manual, learn to use bash. Quote from man bash: -i If the -i option is present, the shell is interactive. -l Make bash act as if it had been invoked as a login shell (see INVOCATION below). ... INVOCATION A login shell is one whose first character of argument zero is a -, or one started with the --login option. An interactive shell is one started without non-option arguments and without the -c option whose standard input and output are both con- nected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state. The following paragraphs describe how bash executes its startup files. If any of the files exist but cannot be read, bash reports an error. Tildes are expanded in file names as described below under Tilde Expan- sion in the EXPANSION section. When bash is invoked as an interactive login shell, or as a non-inter- active shell with the --login option, it first reads and executes com- mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. ... When bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following com- mand were executed: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the PATH variable is not used to search for the file name. ... When bash is started in posix mode, as with the --posix command line option, it follows the POSIX standard for startup files. In this mode, interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read. ... -- René Berber -- 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/