Hi Paul,

On Wed, Apr 8, 2015 at 10:43 AM Paul Moore <[email protected]> wrote:
>
> I normally use ConEmu for my console sessions, and I would like to do
> the same for msys2. How would I start the msys2 shell *without* using
> the supplied batch files? Is it simply a case of setting the MSYSTEM
> environment variable to one of MINGW64, MINGW32, or MSYS and then
> running msys64\usr\bin\sh.exe --login -i?
>
>
While I do not use ConEmu, this is what I do with my own setup. I launch
`sh --login -i` and set my env (PATH, MSYSTEM, PKG_CONFIG_PATH, and the
like) by myself so all tools can find the executables.

To know what env modifications to do, check out the bat scripts and the
file `/etc/profile` which contains everything.

Note that using the bat script make it easy to switch between compilation
toolchains, i.e. between mingw-64 toolchain and msys2 toolchain). But it's
quite possible to do the same without the bat scripts, I do it myself as a
proof.


> Also, I am looking to script some of my builds, using either Python or
> Powershell (using sh isn't an option, for reasons that probably aren't
> important here). How would I do that? Some questions I have are:
>
> 1. Are the --login -i flags essential to correct working? Would I be
> able, for example, to simply run msys64\usr\bin\sh.exe -c "configure;
> make"?
>

 Why running `sh` to invoke commands, why not invoking your python script
directly from terminal? Maybe I don't correctly understand what you are
trying to achieve..

If I want to building multiple packages, I would have a single Python
script I would open my terminal (with the correct env for the toolchain I
want to use) and would simply launch my Python script from the terminal.

2. The standard scripts switch to a directory of /home/<username>. For
> a scripted build, I'd want the msys shell to run in the directory I
> was in when I ran the sh command (as that's where my makefile will
> be). How do I avoid the directory change?
>
>
I guess it's probably a standard bash operation to change working directory
to user's home by default (but I'm not sure, it could be one of the
initialization script that do it).

By default, in MSYS2, the user's home is not the normal Windows home
directory. You can change it however to point to your Windows home, there
is different possibilities, the two most used ones are:

 1. Modifying `/etc/fstab` to change where `/home/$USER` is mounted.
 2. Modify the `/etc/nsswitch.conf`

[1] Method one description (search in issue):
http://ehc.ac/p/msys2/tickets/111/?limit=25&page=0
[2] Method two description (search in issue):
http://sourceforge.net/p/msys2/tickets/98/

For the changing directory when invoking sh, I would say this. Again, why
wrapping your commands with `sh`? Second, see point below about login shell
et al,


>
>
> Setting MSYSTEM and then just running sh.exe seems to leave me with a
> broken PATH (the "mount" command oesn't work, for example). But using
> --login changes my directory. From what I can find, I need
> /etc/profile to run to get a usable PATH, but that seems to change my
> directory, although I can't work out why.
>
> Indeed, `/etc/profile` should be sourced (i.e. read) by bash when using a
login shell to configures the environment correctly. Simply starting `sh`
does not read any files at all.

You can read this blog post about bash, login shell, interactive shell and
startup files: http://airbladesoftware.com/notes/bash-startup-files/

There is probably some way to make it work using `sh` only by inheriting
the parent (caller) environment. I would need to experiment a bit but don't
have much time right now.

I hope I did not confuse you more about this. Don't hesitate to read the
MSYS2 wiki for more information.

Regards,
Matt
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Msys2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to