stop xonsh from loading .bashrc?

314 views
Skip to first unread message

john lunzer

unread,
Dec 12, 2015, 4:41:10 PM12/12/15
to xonsh
It seems to do this automatically. I don't see an obvious way to stop it.

And then also, by what mechanism does xonsh run standard command line executables like "ls" or "ssh"?

And how does __xonsh_ctx__ work into that, I see what looks to be the definition of those command line executables in there?

Anthony Scopatz

unread,
Dec 12, 2015, 4:53:37 PM12/12/15
to john lunzer, xonsh
Hi John, 

On Sat, Dec 12, 2015 at 4:41 PM john lunzer <lun...@gmail.com> wrote:
It seems to do this automatically. I don't see an obvious way to stop it.

This has to be done in the static configuration file.  You can see the docs here: http://xonsh.org/xonshconfig.html

Basically, though, you want to set your "foreign_shells" entry to an empty list, namely:

# disable all foreign shell loading via an empty list
{"foreign_shells": []}
 
And then also, by what mechanism does xonsh run standard command line executables like "ls" or "ssh"?

This is more complicated, but it basically uses Popen except when it uses lower level tools. You can check out the run_subproc() function if you are brave: http://xonsh.org/api/built_ins.html#xonsh.built_ins.

And how does __xonsh_ctx__ work into that, I see what looks to be the definition of those command line executables in there?

That is the eval and/or execution context.  It represents the locals that have been built up in any terminal session.  It is a Python-mode thing not a subproc-mode thing.  The only thing that you are probably seeing in there is that the aliases object is shoved into builtins, and builtins are part of every context (which is a pure Python idea).

Hope this helps!
Be Well
Anthony 

--
You received this message because you are subscribed to the Google Groups "xonsh" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xonsh+un...@googlegroups.com.
To post to this group, send email to xo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xonsh/5895513e-ea0c-4812-8951-8e35d7f2a24b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Asst. Prof. Anthony Scopatz
Nuclear Engineering Program
Mechanical Engineering Dept.
University of South Carolina
sco...@cec.sc.edu
Office: (803) 777-7629
Cell: (512) 827-8239
Check my calendar

john lunzer

unread,
Dec 13, 2015, 10:59:49 AM12/13/15
to xonsh, lun...@gmail.com
Fantastic! I didn't like the idea of piggybacking on any of my other shells. I'm not sure I agree with the the decision to have any foreign shell as default, I don't think this gives xonsh the credit it deserves, though it is a very nice feature to have. Some advanced shells have a first time setup that asks them some questions about features they want to enable, this may be a safer way to handle this as it becomes transparent to the user. As a new user I had no idea xonsh would do this, it's also strange that bash is considered default, there are probably many users coming from zsh where it doesn't make sense to choose bash as the default foreign shell. 

Now I can build up my desired custom commands manually as xonsh aliases, hopefully with far more elegance than bash/zsh scripting. 

One more thing, just so I have a firm grasp of when xonsh decides to process something as a subprocess command, which list/dict/datastructure is xonsh searching through to decide if it should execute in pythonmode or command line mode? It looks like __xonsh_ctx__ but I just want to be sure!

eskhool

unread,
Dec 31, 2015, 4:42:46 AM12/31/15
to xonsh, lun...@gmail.com
Hi Anthony,
 The .bashrc seems to be also getting sourced at every invocation of source-bash. While this may be preferred/expected behavior surely we should document this clearly somewhere? Since I haven't discarded my old bash configs, I've had to move stuff out of bashrc, not painful but wasted some time figuring this out so to save the next noob.

- Anshuman

Anthony Scopatz

unread,
Dec 31, 2015, 1:23:30 PM12/31/15
to eskhool, xonsh, lun...@gmail.com
Hello Anshuman, 

So you are right that this is not documented clearly.  However, if you run `source-bash -h`, you can see that there is a `-i` or `--interactive` option that you can set. The default happens to be true, which isn't documented here clearly enough (PRs welcome!).  I believe that running `source-bash -i false x.sh` will not trigger bash to read from the bashrc file.  From the bash man page, 

"When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists."

If I recall correctly, the reason that interactive defaults to true is so that bash functions can be aliases in xonsh.  I might be mis-remembering that.  It is worth playing around with if you have the time. I am willing to change the default, but I recall we added the interactive mode for a reason at some point.

In any event, I hope this helps. 
Be Well
Anthony


For more options, visit https://groups.google.com/d/optout.

Anthony Scopatz

unread,
Jan 6, 2016, 5:32:10 AM1/6/16
to john lunzer, xonsh
Hi John, 

I just wanted to let everyone know that I now have put in PR #607 configuring the shell initially (or later on).

Hopefully it also serves as a decent walkthrough the foreign shells and the environment variables.

Be Well
Anthony  



For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages