Comments (6)
Originally posted by @bestlem in #5488 (comment)
The issue is that I need to set $PATH and other environment variables. This is done via Login shell in most Unix or the registry in Windows. In macOS/Next nothing sets it.
As for fish they use the --is-interactive flags to stop inclusion of unneeded stuff.
As for zsh it includes ~/.zshenv
bash is the outlier of the current main shells.
Separation of concerns - the script does not set the environment but the initialisation/login shell does.
from xonsh.
Originally posted by @bestlem in #5488 (comment)
Part from the environment issue my main issues here are
-
We must have --no-rc and the opposite to load rc files in shebangs and -i means run interactively and that is independent of not reading rc files, there need to be a separate flag for the opposite of --no-rc reading the default files. (Unfortunately --rc is taken). (This is the error we had in the first place interactive means using the keyboard and not just choosing which files to load)
-
Consistency - I think for most shells the config files in ~ and ~/.config have exactly the same functionality or that only the ons in ~ matter (bash/sh/csh don't understand XDG and zsh needs you to change ZDOTDIR). I don't think anything else reads both. Different behaviour for xonsh could be confusing.
-
Consistency - I think all shells read both the ones in home and /etc or they read none. Does xonsh have a reason to do differently?
I can accept the current suggestion but points 2 & 3 have to be documented
There needs to be a flag to run xonsh scripts reading config files in non-interactive mode,
I sort of accept the comment about piping things >> .xonshrc but that is really bad documentation of the program providing the setup - as I note several projects do get this correct for fish and several don't - In general there are a lot of projects that just assume GNU/Linux and so bash and don"t do things cross platform - bash does have a test for interactive or not (found in the nix generated file)
# Commands that should be applied only for interactive shells.
[[ $- == *i* ]] || return
below here are all aliases and prompt stuff
There are reasons not to want to use bash
from xonsh.
@bestlem thank you for explanation but I think I can't understand this without examples but I want to help you.
This can help me understand the case:
- repetable environement like docker with list of commands that I can repeat and faced with problem
- OR the list of commands you're doing the result you're getting and explain where is the problem and why.
I'm manjaro/macos user where I have never faced with any kind of rc issues. I understand how xonsh is working. I want to help you. But I really don't understand what exactly you're doing, what you expect and what is the problem.
I want to give you group of random commands to confirm that you know this and confirm that you can't construct the solution from this.
# xonsh 0.17.0
xonsh -DPATH=/tmp -DXONSHRC=file1:file2 # overwrite any env variables
xonsh --no-env # do not inherit environment AND use xonsh own default
xonsh --rc file1 file2 # list of rc files to load
xonsh --no-rc # disable rc files
xonsh -i # load all possible rc files (after 5491)
xonsh --no-env -DXONSHRC= -DXONSHRC_DIR=/my/path # combination
# Defaults
$XONSHRC
# ('/etc/xonsh/xonshrc', '/USERHOME/.config/xonsh/rc.xsh', '/USERHOME/.xonshrc')
$XONSHRC_DIR
# ('/etc/xonsh/rc.d', '/USERHOME/.config/xonsh/rc.d')
There is no way to solve your issue with this?
from xonsh.
xonsh -i means run setting $XONSH_INTERACTIVE it should say nothing about reading startup files.
Running with startup files is a separate concept - how do you run a non-interactive shell loading the default startup files. (OK I can't see a case for xonsh -i not loading startup files except for some debugging but that is not the issue it is xonsh without the -i)
This is the same points I made in #4096 see my comment of Mar 6, 2021 and @Eximius"s comment
There has to be a case that
xonsh -some-flag script.xsh runs
and $XONSH_INTERACTIVE is false and the standard startup files are read. To match fish and zsh I would expect no flag here but can deal with having to provide a flag.
from xonsh.
There has to be a case that xonsh -some-flag script.xsh runs and $XONSH_INTERACTIVE is false and the standard startup files are read.
Xonsh defaults:
# Defaults
$XONSHRC
# ('/etc/xonsh/xonshrc', '/USERHOME/.config/xonsh/rc.xsh', '/USERHOME/.xonshrc')
$XONSHRC_DIR
# ('/etc/xonsh/rc.d', '/USERHOME/.config/xonsh/rc.d')
@bestlem I'm wondering why you can't put the configs you need in ('/etc/xonsh/rc.d', '/USERHOME/.config/xonsh/rc.d')
after #5099 was merged and checking for XONSH_INTERACTIVE
and XONSH_LOGIN
?
from xonsh.
from xonsh.
Related Issues (20)
- Process and subprocess
- Refactoring: parser
- Refactoring: operators
- Refactoring: aliases
- Faded blue color HOT 1
- Warlus in python substitution: NamedExpr target must be a Name
- Edge case: `TERM=dumb xonsh -i` hangs indefinitely if stdin is non-interactive
- Edge case: `xonsh --no-rc --no-env`: `TERM environment variable not set`
- Main branch regress: redirect to python substitution HOT 3
- Windows: case of commands is incorrectly upper-cased on Windows HOT 7
- Completion: `act, _, value = act_res`: `Exception too many values to unpack (expected 3)` HOT 1
- Windows: Don't imply PATH=. HOT 7
- Edge case: `source file.xonshrc` shows `attempting to source non-xonsh file`
- Piping into the process that was ended immediately leads to exceptions with descriptors HOT 1
- Disable loading xonshrc in xonsh pytest plugin HOT 1
- Unintended loading `xonshrc` file in script mode HOT 15
- Colorize stderr
- Windows: support windows paths in environment HOT 1
- Refactoring: review interactive functionality
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xonsh.