This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: chere not seeing my preferred $HOME
- From: "Rainer Blome" <rainer dot blome at gmx dot de>
- To: "Nellis, Kenneth" <Kenneth dot Nellis at xerox dot com>
- Cc: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Thu, 30 Jun 2016 23:11:58 +0200
- Subject: RE: chere not seeing my preferred $HOME
- Authentication-results: sourceware.org; auth=none
- References: <trinity-63d84bf2-3537-4dc9-bd09-fd297e17bc5b-1467314772125 at 3capp-gmx-bs40>, <0D835E9B9CD07F40A48423F80D3B5A704BB77F14 at USA7109MB022 dot na dot xerox dot net>
- Sensitivity: Normal
> Gesendet: Donnerstag, 30. Juni 2016 um 21:55 Uhr
> Von: "Nellis, Kenneth"
> Hello. http://www.cygwin.com/acronyms/#PCYMTNQREAIYR
Sorry, forgot, thanks for pointing it out.
> I simply want chere to run my .profile before it presents
> me with the bash prompt.
How to achieve that depends on your shell.
For example, .bash_profile is not read for every bash instance.
See section INVOCATION of `man bash`, where details are
given which file is read when (or not).
My solution is to conditionally read `.profile` from the shell-specific
`.XYZshrc` file. See a part of my `.bashrc` below, as an appendix.
> I guess the problem is knowing how to tell chere what
> my Cygwin $HOME is.
My understanding is that for the same cygwin user,
$HOME should always have the same value,
regardless of where you used "Bash Prompt Here".
Clicking that in C:\cygwin\etc yields a shell that behaves
like this for me:
/etc> echo $HOME
/cygdrive/c/blome # That's what I have configured.
> Using the word "domain" generically, there is my Windows
> domain ($HOME is C:\Users\KNellis) and my Cygwin domain
> ($HOME is C:\cygwin\home\knellis).
I think I still don't understand what you mean by domain.
> > > Hoping I can keep the two domains separate.
And I'm not sure what you mean by "keep separate".
The paths you gave above are directories, which are obviously
(hopefully ;-) already separate.
Under Cygwin, in a shell, $HOME should have a value with slashes,
`/home/knellis` in your case, true?
In a windows terminal ("Command Prompt"), `$HOME` does not
refer to an environment variable (those would use `%XYZ%`).
For me, the environment variable named HOME is not set.
`echo %HOME%` yields literally `echo %HOME%`.
Looking through the output of `set`, there are two variables
that contain my windows user's home directory, HOMEPATH
(without the drive letter) and USERPROFILE.
> chere appears to be using my Windows domain,
That would be surprising indeed.
> which doesn't have a .bash_profile,
> but I'd like it to use my Cygwin domain.
> > > chere> echo $HOME; cygpath -w $HOME
> > > /cygdrive/c/Users/KNellis
> > > C:\Users\KNellis
What does "chere" mean here?
How exactly did you get this shell?
Which commands did you type, what did you click?
Repeat:
> > How come you have differing values for $HOME in some contexts?
> Different domains.
In the context of my above questions, can you give a more precise answer?
Rainer
----
# Regarding initialization files, Bash knows 3 different shells:
# o A "normal", non-interactive shell, such as in "bash -c 'echo Hello'",
# does not load any file.
# o An interactive shell, one that reads commands from a terminal, is
# supposed to read "~/.bashrc".
# o A login shell is supposed to read "~/.profile".
# When an interactive login shell is started, Bash loads the .bashrc
# first, then the .profile.
# --------------------------------------------------------------------
#debug="true";
note() { echo 1>&2 "$@"; }
c() { if [ ! "" = "${debug-}" ]; then note "$*"; fi; }
# Reentrance handling
if [ ! "" = "${home_bashrc_was_read-}" ]; then
c ".bashrc: Warning, .bashrc reentered (possible recursion).";
# FIXME: Simply continuing would make it easier to reload this file.
if [ "" = "${debug-}" ]; then
c ".bashrc stopped.";
return 0;
else
c "Continuing .bashrc (because we are in debug mode).";
fi;
fi;
# Keep this here, don't move it to the end of the file.
# We just want to know whether it was tried to read
# this, not whether it was successful.
home_bashrc_was_read="true"; # Do not export this!
c .bashrc running...
# --------------------------------------------------------------------
# FIXME: This assumes that the $HOME value is valid, which it may not
# be. For example, on Windows, $HOME may be "C:/" instead of anything
# actually user-specific.
if [ "" = "${HOME_PROFILE_WAS_READ-}" ]; then
c ".bashrc: Sourcing '.profile'...";
. "$HOME/.profile";
c ".bashrc: Sourced '.profile'.";
fi;
----
--
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