all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alexander Shukaev <haroogan@gmail.com>
To: tomas@tuxteam.de
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Autogen in Emacs Shell
Date: Fri, 1 May 2015 16:33:04 +0200	[thread overview]
Message-ID: <CAKu-7Wzh3yqOzmFp=ZNeGjVRkOJ_aTMzsZ0-E=_6k2Kww9tWDg@mail.gmail.com> (raw)
In-Reply-To: <20150501092657.GA19316@tuxteam.de>

[-- Attachment #1: Type: text/plain, Size: 2754 bytes --]

​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;~\a
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, <tomas@tuxteam.de> 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-----
>

[-- Attachment #2: profile --]
[-- Type: application/octet-stream, Size: 5430 bytes --]

# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty. 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. 
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 


# System-wide profile file

# Some resources...
# Customizing Your Shell: http://www.dsl.org/cookbook/cookbook_5.html#SEC69
# Consistent BackSpace and Delete Configuration:
#   http://www.ibb.net/~anne/keyboard.html
# The Linux Documentation Project: http://www.tldp.org/
# The Linux Cookbook: http://www.tldp.org/LDP/linuxcookbook/html/
# Greg's Wiki http://mywiki.wooledge.org/

# Setup some default paths. Note that this order will allow user installed
# software to override 'system' software.
# Modifying these default path settings can be done in different ways.
# To learn more about startup files, refer to your shell's man page.

MSYS2_PATH="/usr/local/bin:/usr/bin:/bin"
MANPATH="/usr/local/man:/usr/share/man:/usr/man:/share/man:${MANPATH}"
INFOPATH="/usr/local/info:/usr/share/info:/usr/info:/share/info:${INFOPATH}"
MINGW_MOUNT_POINT=
if [ -n "$MSYSTEM" ]
then
  case "$MSYSTEM" in
    MINGW32)
      MINGW_MOUNT_POINT=/mingw32
      PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}"
      PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
      ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
      MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
    ;;
    MINGW64)
      MINGW_MOUNT_POINT=/mingw64
      PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}"
      PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
      ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
      MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
    ;;
    MSYS)
      PATH="${MSYS2_PATH}:/opt/bin:${PATH}"
      PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig"
    ;;
    *)
      PATH="${MSYS2_PATH}:${PATH}"
    ;;
  esac
else
  PATH="${MSYS2_PATH}:${PATH}"
fi

MAYBE_FIRST_START=false
SYSCONFDIR="${SYSCONFDIR:=/etc}"

# TMP and TEMP as defined in the Windows environment must be kept
# for windows apps, even if started from msys2. However, leaving
# them set to the default Windows temporary directory or unset
# can have unexpected consequences for msys2 apps, so we define 
# our own to match GNU/Linux behaviour.
ORIGINAL_TMP=$TMP
ORIGINAL_TEMP=$TEMP
unset TMP TEMP
tmp=$(cygpath -w "$ORIGINAL_TMP" 2> /dev/null)
temp=$(cygpath -w "$ORIGINAL_TEMP" 2> /dev/null)
TMP="/tmp"
TEMP="/tmp"

# Define default printer
p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
if [ -e "${p}" ] ; then
  read -r PRINTER < "${p}" 
  PRINTER=${PRINTER%%,*}
fi
unset p

print_flags ()
{
  (( $1 & 0x0002 )) && echo -n "binary" || echo -n "text"
  (( $1 & 0x0010 )) && echo -n ",exec"
  (( $1 & 0x0040 )) && echo -n ",cygexec"
  (( $1 & 0x0100 )) && echo -n ",notexec"
}

# Shell dependent settings
profile_d ()
{
  local file=
  for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
    [ -e "${file}" ] && . "${file}"
  done
  
  if [ -n "${MINGW_MOUNT_POINT}" ]; then
    for file in $(export LC_COLLATE=C; echo ${MINGW_MOUNT_POINT}/etc/profile.d/*.$1); do
      [ -e "${file}" ] && . "${file}"
    done
  fi
}

for postinst in $(export LC_COLLATE=C; echo /etc/post-install/*.post); do
  [ -e "${postinst}" ] && . "${postinst}"
done

if [ ! "x${BASH_VERSION}" = "x" ]; then
  HOSTNAME="$(/usr/bin/hostname)"
  profile_d sh
  [ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
elif [ ! "x${KSH_VERSION}" = "x" ]; then
  typeset -l HOSTNAME="$(/usr/bin/hostname)"
  profile_d sh
  PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
elif [ ! "x${ZSH_VERSION}" = "x" ]; then
  HOSTNAME="$(/usr/bin/hostname)"
  profile_d zsh
  PS1='(%n@%m)[%h] %~ %% '
elif [ ! "x${POSH_VERSION}" = "x" ]; then
  HOSTNAME="$(/usr/bin/hostname)"
  PS1="$ "
else 
  HOSTNAME="$(/usr/bin/hostname)"
  profile_d sh
  PS1="$ "
fi

if [ -n "$ACLOCAL_PATH" ]
then
  export ACLOCAL_PATH
fi

export PATH MANPATH INFOPATH PKG_CONFIG_PATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp
export TERM=xterm-256color
unset PATH_SEPARATOR

if [ "$MAYBE_FIRST_START" = "true" ]; then
  sh /usr/bin/regen-info.sh
  
  if [ -f "/usr/bin/update-ca-trust" ]
  then 
    sh /usr/bin/update-ca-trust
  fi

  clear
  echo
  echo
  echo "###################################################################"
  echo "#                                                                 #"
  echo "#                                                                 #"
  echo "#                   C   A   U   T   I   O   N                     #"
  echo "#                                                                 #"
  echo "#                  This is first start of MSYS2.                  #"
  echo "#       You MUST restart shell to apply necessary actions.        #"
  echo "#                                                                 #"
  echo "#                                                                 #"
  echo "###################################################################"
  echo
  echo
fi
unset MAYBE_FIRST_START

  reply	other threads:[~2015-05-01 14:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29  2:36 Autogen in Emacs Shell Alexander Shukaev
2015-04-29  8:31 ` tomas
2015-04-29 15:51 ` Eli Zaretskii
2015-04-30 18:14   ` Alexander Shukaev
2015-04-30 19:26     ` Eli Zaretskii
2015-04-30 19:44       ` Alexander Shukaev
2015-04-30 19:54         ` Eli Zaretskii
2015-05-01  9:26     ` tomas
2015-05-01 14:33       ` Alexander Shukaev [this message]
2015-05-01 14:46         ` Alexander Shukaev
2015-05-01 15:03         ` tomas
2015-05-01 16:08           ` Alexander Shukaev
2015-05-01 17:06             ` Alexander Shukaev
2015-05-01 17:49               ` Eli Zaretskii
2015-05-01 18:35                 ` Alexander Shukaev
2015-05-01 18:51                   ` Eli Zaretskii
2015-05-01 19:05                     ` Alexander Shukaev
2015-05-01 19:07                       ` Alexander Shukaev
2015-05-01 19:26                       ` Eli Zaretskii
2015-05-01 19:38                   ` Eli Zaretskii
2015-05-01 19:46                     ` Alexander Shukaev
2015-05-02  6:31                       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKu-7Wzh3yqOzmFp=ZNeGjVRkOJ_aTMzsZ0-E=_6k2Kww9tWDg@mail.gmail.com' \
    --to=haroogan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tomas@tuxteam.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.