​My goodness, this is so weird. I start to hate that, sigh... T_T So to check that it's indeed "/etc/profile" involved in changing to "~". I do the following: 1. Start 'bash' with "M-x bash RET": (defun bash (&optional buffer) (interactive) (let ((explicit-shell-file-name "bash") (explicit-bash-args '("--noediting" "-i"))) (setq buffer (my-call shell buffer))) (with-current-buffer buffer (when (equal (buffer-name) "*shell*") (rename-buffer "*bash*" t)))) ​NOTE: `my-call' macro just properly handles whether to `call-interactively' or not.​ 2. I have "~/emacs.d/init_bash.sh" with . /etc/profile As a result, here is what I see when I start `bash' from some buffer which contains file with path let's say "~/dir/file": 2015.05.01 Friday 16:07:21 Haroogan@G75VW:~/dir $ ]0;~ Haroogan@G75VW ~ $ A few points here. 1. The first prompt is of course mine (coming from ".bashrc"). 2. Then there goes garbage, it's a separate story by the way. I think I discovered a bug: this garbage appears when there is some content in "~/emacs.d/init_bash.sh". Does not matter what kind of content that is, e.g. it could be even be comments. The main point is that the number of those garbage lines that will appear on the start of `bash' is equal to the number of lines written in "~/emacs.d/init_bash.sh". Like in this case, we just have one line in "~/emacs.d/init_bash.sh", so the garbage appears one time. I mean it's like it really types those newlines into shell. 3. Finally there is another prompt which is obviously coming from the sourced "/etc/profile". I've scanned "/etc/profile" and other files that it sources. There is no evidence of `cd' to "~". I'm attaching it here, can you find anything that would change to "~"? Thank you. ​Regards, Alexander​ On Fri, May 1, 2015 at 11:26 AM, wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Thu, Apr 30, 2015 at 08:14:08PM +0200, Alexander Shukaev wrote: > [...] > > > [login shell, check env variables] > > > Yes, I'm going to try that. One thing I don't like about "--login" > though > > is that it forces `bash' to `cd' to '~'. > > Just tried it: bash --login doesn't cd to my $HOME, it just stays "where > it is". > Perhaps one of your *profiles (/etc/profile, ~/.profile, ~/.bash_profile or > however those are called in Cygwin-land) is cd-ing to $HOME? > > regards > - -- tomás > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.12 (GNU/Linux) > > iEYEARECAAYFAlVDRuEACgkQBcgs9XrR2kZB0wCcCBCmzwjRSBZ0vgw+DTDqSk+5 > pWEAn1e5EknL1CaN7gymA51pbbFSljy5 > =MzOv > -----END PGP SIGNATURE----- >