Commit graph

10687 commits

Author SHA1 Message Date
a
2b79ef3691 print 2024-06-27 03:34:10 +02:00
Noorhteen Raja NJ
0f2011d302
fix: Fixed `history gc invocation failing when sqlite` history … (#5540)
…backend is used.


## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
2024-06-26 13:19:26 +05:30
Andy Kipp
a52aa5febc
Command cache: fix update cache logic (#5539)
### Motivation

I noticed that when I type every letter in the prompt on the remote
server the typing is lagging. I thought it's ssh but no.
After inspection the commands cache code I found that on every key press
there is reading all 2000+ files in PATH because the code for cache
update has funny issue.

### Quiz

```xsh
def f():
    print(1)
    yield False
    print(2)
    yield True
    print(3)

print(any(f()))
```
What will be in the output? Answer:

<details>

```
1
2
True
```

The execution of `print(3)` ignored because `any()` interrupts the
execution of the function.
If we call `print(list(f()))` the output will be `1 2 3 [False, True]`.

</details>

### Before

* Updating cache (read all files in PATH and list of aliases) two times
after start.
* Updating cache (read all files in PATH and list of aliases) on every
key press in prompt.

### After

* Update cache once at start.
* Update cache only when we have real changes of paths or aliases.

cc #4954 #3895 #5309

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-26 12:02:51 +05:30
Andy Kipp
4fb3c79ede
environ docs: move variables to new sections (#5501)
### Motivation

Section "General" in https://xon.sh/envvars.html became huge. It's time
to add new sections and just move vars to them.

Example of the most expected sections:
* cache
* subprocess
* locale

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-25 22:36:05 +05:30
Andy Kipp
0b65348d5e
prompt: switching to prompt_toolkit in case of stdin with interactive mode (#5536)
### Motivation

There is an edge case that we're using mostly in integration tests from
the beginning of the world:
`echo 'echo 1' | xonsh -i` and it's not working with `TERM=dumb` because
dumb is readline.
So in this case we need to force using prompt_toolkit to avoid hanging.

Closes #5462 #5517

### Before

These all produces hanging because reading stdin is not implemented in
readline backend:
```xsh
echo whoami | TERM=dumb xonsh -i --no-rc   # dumb is readline in fact
# or the same
echo whoami | xonsh -st dumb -i  # dumb is readline in fact
# or the same
echo whoami | xonsh -st readline -i
```

### After

Switching to prompt_toolkit in these cases.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-25 21:34:14 +05:30
a
584a84d645 news 2024-06-25 00:46:32 +02:00
a
1faca101ab fix 2024-06-24 21:46:09 +02:00
Andy Kipp
d351df384a
tests: SpecAttrModifierAlias: integration test (#5533)
Added test.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-24 15:12:23 -04:00
Andy Kipp
3e41a744d4
sqlite3: optional loading (#5534)
After testing xonsh on ALT linux
(https://github.com/xonsh/xonsh/issues/5517#issuecomment-2187069017) I
see that we need to make sqlite3 loading optional.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-24 15:11:55 -04:00
Andy Kipp
934351254a
docs: SpecModifierAlias to the tutorial (#5518)
Added SpecModifierAlias (#5443) to the tutorial.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
2024-06-24 14:28:39 -04:00
pre-commit-ci[bot]
105942d4d4
[pre-commit.ci] pre-commit autoupdate (#5535)
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.9 →
v0.4.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.9...v0.4.10)
<!--pre-commit.ci end-->

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-24 20:14:39 +02:00
Andy Kipp
9f0bf03753
xonsh.lib: minor docstring (#5529)
Closes #2726. Self merge minor doc.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-23 03:16:52 +02:00
Andy Kipp
c3e1bd106f
Micro update README.rst (#5528)
Change the moto like in other places. Self merge.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
2024-06-22 22:53:50 +02:00
Andy Kipp
93e493afd0
Update AppImage README.rst (#5523)
<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

Minor, self merge

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
2024-06-21 10:33:21 +02:00
Andy Kipp
295e7f0582
xonshrc: add docs and tests for py files (#5515)
* Added py mention to docs
* Added tests
* Microfix

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-20 14:02:48 +00:00
Andy Kipp
60db3e6138
fix main page (#5514)
* fix section
* added link to latest release

Please update https://xon.sh after merge this.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-06-20 09:37:50 -04:00
lunrenyi
80d68f583b
Update README.rst (#5513)
Add x-cmd to the projects-that-use-xonsh-or-compatible list

x-cmd is a toolset implemented using posix shell and awk. It is very
small in size and offers many interesting features. Here is a milestone
demo: https://www.x-cmd.com/mod/onsh

<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-18 18:15:49 +02:00
Gil Forsyth
5332d75505 Updated CHANGELOG for 0.17.0 2024-06-18 08:47:50 -04:00
Gil Forsyth
fe8448c2c1 bumped version to 0.17.0 2024-06-18 08:47:50 -04:00
Gil Forsyth
9901bc442a Updated authorship for 0.17.0 2024-06-18 08:47:50 -04:00
Andy Kipp
4e12834e84
spec: added raise_subproc_error (#5494)
### Motivation

Add `spec.raise_subproc_error` to have an ability to use
`SpecModifierAlias` to manage the errors. Also this is the first step to
#4351.

Generally in scripts it's good to have RAISE_SUBPROC_ERROR=True to avoid
processing the error for every executed command. But in some cases (e.g.
`![]`) it's needed to avoid raising the error. To more elegant doing
this we can make an ability to create SpecModifier.

### After

```xsh
from xonsh.procs.specs import SpecModifierAlias
class SpecModifierNoErrAlias(SpecModifierAlias):
    def on_modifer_added(self, spec):
        spec.raise_subproc_error = False
aliases['noraise'] = SpecModifierNoErrAlias()

$RAISE_SUBPROC_ERROR = True

if ![noraise git pull]:
    git add --all
```

Cc #5443 

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-18 08:43:10 -04:00
pre-commit-ci[bot]
6b9f6ba0e1
[pre-commit.ci] pre-commit autoupdate (#5510)
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.8 →
v0.4.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.8...v0.4.9)
<!--pre-commit.ci end-->

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-17 20:44:50 +02:00
Andy Kipp
09a89bf9b4
docs: install xonsh as a core shell (#5504)
### Motivation

I'm using [xonsh-install](https://github.com/anki-code/xonsh-install)
pretty long time and I see that it works pretty predictable, expected
and stable. I suggest to mention this approach in our docs to get more
attention and testing around this from users and some day move
xonsh-install to the xonsh project.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-17 13:17:10 -04:00
Andy Kipp
09bdfaee00
coreutils which: fix none matching (#5508)
After #5379 #5432 we need to check None.

Closes https://github.com/anki-code/xontrib-argcomplete/issues/10

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-06-17 12:55:54 +02:00
a
de50a09a6c Merge remote-tracking branch 'origin/main' 2024-06-15 22:14:32 +02:00
Andy Kipp
d30d0a5446
docs: more links to xonshrc article (#5505)
After #5099 #5491 we need more links to xonshrc article in our docs. So
I've added them.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
2024-06-15 18:32:32 +02:00
Andy Kipp
f9d2842fb1
docs: move section "Use the Nix Package manager with Xonsh" from rc to platform tips and tricks (#5503)
<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

subj

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
2024-06-15 18:31:50 +02:00
Andy Kipp
40f5eea840
devguide: fix knight vs snail pic (#5502)
### Before

<img width="762" alt="image"
src="https://github.com/xonsh/xonsh/assets/1708680/21b3620c-cbf3-489d-b5c7-0f8d92cdfb01">


### After

<img width="760" alt="image"
src="https://github.com/xonsh/xonsh/assets/1708680/4f61b77b-8e99-4372-9aac-1d13a6ee8e1f">


## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-06-15 09:28:00 +02:00
a
fcc3b779c3 fix knight vs snail! 2024-06-14 22:26:02 +02:00
Andy Kipp
01169c9041
xonfig: added links (#5500)
Added links to xontribs in `xonfig web`

### After

<img width="764" alt="image"
src="https://github.com/xonsh/xonsh/assets/1708680/cf5a32e6-f04c-4718-a175-2bfc863632ba">


## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-14 14:04:09 +00:00
Andy Kipp
06aca868a2
Fix #5491: more tests (#5498)
Fix #5491: 
* fix condition
* added more well organized tests

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-14 07:39:16 +02:00
Andy Kipp
5ee386eed9
Fix after #5491 (#5497)
After #5491 there is one case unfixed:

### Before
```xsh
echo 'echo home' >> ~/.xonshrc
cd /tmp
echo 'echo script' > 1.xsh

xonsh 1.xsh
# all rc without ~/.xonshrc
# script
xonsh -i 1.xsh
# all rc without ~/.xonshrc  # bug
# script
```

### After

```xsh
echo 'echo home' >> ~/.xonshrc
cd /tmp
echo 'echo script' > 1.xsh

xonsh 1.xsh
# all rc without ~/.xonshrc
# script
xonsh -i 1.xsh
# all rc with ~/.xonshrc
# home    # FIX
# script
```

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-13 17:19:21 +02:00
Andy Kipp
f81d55d09b
Do not load ~/.xonshrc in not interactive mode (#5491)
### Motivation

In #5099 was introduced the logic where all RC files are loaded in
interactive and non-interactive modes. This logic is not working good
for home based `~/.xonshrc` file.

First of all `~/.xonshrc` is the buffer/accumulator of settings focused
on interactive mode. Most tools with integration with xonsh (e.g.
`conda`, `zoxide`, etc) offer to just do `echo "init_tool()" >>
~/.xonshrc` (`conda` has around 20 lines of init code) to start using
the tool and users are doing this without any doubts.

But because of after 5099 `~/.xonshrc` is executed in non-interactive
mode the adding code to it leads to unexpected and unintended side
effects:

* If you run a script with shebang (e.g. `#!/usr/bin/env xonsh` or
[xonsh-awesome-cli-app](https://github.com/anki-code/xonsh-awesome-cli-app))
or just from `xonsh script.xsh` the code will be unexpected and
unintended slower.

* If you're using xonsh-based tools (e.g. you install them using pip)
and run them in environment that has no packages that initiated in
`~/.xonshrc` you will see epic errors.

* Additional context: 
* Bash and Zsh do not load `~/.bashrc` and `~/.zshrc` in non-interactive
mode by the same reasons.
* We have welcome message `Create ~/.xonshrc file manually or use xonfig
to suppress the welcome message` and we don't want to make the process
of creating this file complex.

All of this leads to bad unexpected and unintended experience. This PR
is to fix this.

### Expectation

By doing this fix we assume that experienced user who wants to build
good repeatable run control files will use another ways to create config
files and this has [reflection in
docs](8860f2bd52/docs/xonshrc.rst).
In the nutshell if you want to create the RC files that affect every run
of code you should use one or many of these ways:

* Cross-desktop group (XDG) compliant `~/.config/xonsh/rc.xsh` control
file.
* The system-wide control file `/etc/xonsh/xonshrc` for Linux and OSX
and in `%ALLUSERSPROFILE%\xonsh\xonshrc` on Windows. It controls options
that are applied to all users of Xonsh on a given system.
* The home-based directory `~/.config/xonsh/rc.d/` and system
`/etc/xonsh/rc.d/` can contain .xsh files. They will be executed at
startup in order. This allows for drop-in configuration where your
configuration can be split across scripts and common and local
configurations more easily separated.

In your configs you need to check `$XONSH_INTERACTIVE` and
`$XONSH_LOGIN` explicitly.

### Before

`~/.xonshrc` is used in non-interactive mode.

```xsh
echo "echo RC" >> ~/.xonshrc
cd /tmp
echo "echo Script" > script.xsh
xonsh script.xsh
# RC
# Script
```
```xsh
cd /tmp
echo 'echo RC' >> ~/.xonshrc
echo '#!/usr/bin/env xonsh' > myscript
chmod +x myscript

./myscript
# RC
```

### After

`~/.xonshrc` is not used in non-interactive mode. Use `-i` if you need
it.

```xsh
echo "echo RC" >> ~/.xonshrc
cd /tmp
echo "echo Script" > script.xsh
xonsh script.xsh
# Script

xonsh -i script.xsh
# RC
# Script
```
```xsh
cd /tmp
echo 'echo RC' >> ~/.xonshrc
echo '#!/usr/bin/env xonsh' > myscript
chmod +x myscript

./myscript
```
Closes #5488 #4096 #5496

### Fun

I want to leave here some nice representation of how it works in
bash/sh/zsh from [twitter
post](https://twitter.com/paxx39/status/1742768007154479109):



![image](https://github.com/xonsh/xonsh/assets/1708680/cd7b3803-483f-4d5d-bf9d-baa61c794f68)


## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-13 10:08:23 -04:00
Andy Kipp
0d28a6731b
Micro update new-issue.md (#5490)
<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
2024-06-11 17:25:10 +02:00
pre-commit-ci[bot]
0ed58e60c9
[pre-commit.ci] pre-commit autoupdate (#5486)
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.7 →
v0.4.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.7...v0.4.8)
<!--pre-commit.ci end-->

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-10 21:33:37 +02:00
Jason R. Coombs
4aec6d1d12
Perform proper case-insensitive matching in command_cache on Windows (#5477)
Closes #5476
Closes #5469
2024-06-10 12:29:13 -04:00
amacfie-tc
8e229a421f
Add Starship to xonsh-compatible projects (#5484)
## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2024-06-10 18:25:31 +02:00
Andy Kipp
63da8e3492
Tutorial: Callable alias and capturing (#5472)
<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
2024-06-10 09:42:00 -04:00
Andy Kipp
81df360e9d
spec: added output_format (#5481)
This is continuation for introduced before
`$XONSH_SUBPROC_OUTPUT_FORMAT` (#5377) so news file is not needed.

### Motivation

Having `output_format` in spec and in pipeline allows to switch output
format in `SpecModifierAlias` and during non-blocking work e.g.
```xsh
p=!(echo '1\n2\n3')
p.output_format = 'list_lines'
p.out
# ['1','2','3']
```
```xsh
from xonsh.procs.specs import SpecModifierAlias
class SpecModifierOutputLinesAlias(SpecModifierAlias):
    def on_modifer_added(self, spec):
        spec.output_format = 'list_lines'
aliases['xlines'] = SpecModifierOutputLinesAlias()

$(xlines echo '1\n2\n3')
# ['1','2','3']
```

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-10 09:38:53 -04:00
a
9e86938c4d update 2024-06-07 17:03:49 +02:00
pre-commit-ci[bot]
5afb83d67e
[pre-commit.ci] pre-commit autoupdate (#5479)
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.5 →
v0.4.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.5...v0.4.7)
<!--pre-commit.ci end-->

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-03 20:03:09 +02:00
Andy Kipp
c89a7267be
list_lines: list for single line output (#5478)
### Motivation

This is fix for introduced before
`$XONSH_SUBPROC_OUTPUT_FORMAT='list_lines'` so news file is not needed.

We should return the list for single line output to avoid unintended
reading the string.

### Before
```xsh
$XONSH_SUBPROC_OUTPUT_FORMAT='list_lines'
mkdir -p /tmp/list_lines
cd /tmp/list_lines
touch 123

du $(ls)
# 0	123

for f in $(ls):
    print(f)
# 1
# 2
# 3

touch 321

for f in $(ls):
    print(f)
# 123
# 321
```

### After

```xsh
$XONSH_SUBPROC_OUTPUT_FORMAT='list_lines'
mkdir -p /tmp/list_lines
cd /tmp/list_lines
touch 123

du $(ls)
# 0	123

for f in $(ls):
    print(f)
# 123

touch 321

for f in $(ls):
    print(f)
# 123
# 321
```


## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-06-02 16:33:34 +02:00
Andy Kipp
850bd8f34b
Revert "Revert #5423" (#5475)
Reverts xonsh/xonsh#5468

Closes #5466

Related #5423

---------

Co-authored-by: a <1@1.1>
2024-06-02 14:53:00 +02:00
Andy Kipp
6245e460a6
Tutorial: micro about exec alias args (#5474)
Replaced too emotional warning.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-06-01 22:35:25 +02:00
Andy Kipp
c9046ab3f6
Revert #5423 (#5468)
I'm going to revert #5423 because it was regress -
https://github.com/xonsh/xonsh/issues/5466 - and we need to fix parser
instead of resolver.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
2024-05-31 22:59:59 +02:00
Andy Kipp
b0b1fe0ac1
XONSH_TRACE_SUBPROC docs (#5467)
## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-05-31 17:37:01 +02:00
Andy Kipp
2908f4da17
SpecModifierAlias: micro move (#5464)
It's needed to put spec modifier to the end of resolving.

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-05-31 17:36:02 +02:00
Andy Kipp
aaf3c99a3b
Added `$XONSH_TRACE_SUBPROC=3` (#5459)
Show std if `$XONSH_TRACE_SUBPROC=3`.

### Motivation

* It's very helpful if you want to understand how subproc is working. 
* It's helpful to trace `SpecModifierAlias`.
* It's helpful to trace cases like #2618

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-31 12:50:25 +02:00
jyn
a953c29443
allow test_raise_subproc_error_with_show_traceback to be run locally (#5461)
previously, this succeeded in CI, but always failed locally with the
following error:
```xsh
_____________________________________________________________________ test_raise_subproc_error_with_show_traceback[True] _____________________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x76f6ba8882e0>, interactive = True

    @skip_if_on_windows
    @pytest.mark.parametrize("interactive", [True, False])
    def test_raise_subproc_error_with_show_traceback(monkeypatch, interactive):
        out, err, ret = run_xonsh(
            "$COLOR_RESULTS=False\n$RAISE_SUBPROC_ERROR=False\n$XONSH_SHOW_TRACEBACK=False\nls nofile",
            interactive=interactive,
            single_command=True,
        )
        assert ret != 0
>       assert re.match("ls.*No such file or directory\n", out)
E       assert None
E        +  where None = <function match at 0x76f6bcd0cd30>('ls.*No such file or directory\n', "\x1b]0;ls | jyn@pop-os: ~/src/xonsh | xonsh\x07ls: cannot access 'nofile': No such file or directory\n")
E        +    where <function match at 0x76f6bcd0cd30> = re.match

tests/test_integrations.py:1190: AssertionError
```

the problem was that the following string was prepended before the error
message:
```
\x1b]0;ls | jyn@pop-os: ~/src/xonsh | xonsh\x07l
```

that in turn came from
[`BaseShell.settitle`](66c0490d37/xonsh/base_shell.py (L570)),
which always prepends at least the escape codes even when TITLE is set
to an empty string.

avoid this issue by mimicking a dumb terminal in tests, in which case
`settitle` doesn't add any title at all.

see
https://xonsh.zulipchat.com/#narrow/stream/435069-xonsh-dev/topic/Running.20tests.20locally
for more context.
<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
2024-05-30 17:02:53 +02:00
jyn
fccdd021c4
note that xonsh requires pip 24 for an editable install and development (#5460)
with pip 22, i was getting extremely strange errors like this one:
```
$ pip install '.[dev]'
Processing /home/jyn/src/xonsh
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
WARNING: unknown 0.0.0 does not provide the extra 'dev'
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (pyproject.toml) ... done

Successfully installed UNKNOWN-0.0.0
$ pytest
tests/test_lib/test_subprocess.xsh:10: in <module>
    from xonsh.pytest.tools import ON_WINDOWS
E   ModuleNotFoundError: No module named 'xonsh.pytest'
```

see
https://xonsh.zulipchat.com/#narrow/stream/435069-xonsh-dev/topic/install.20xonsh.20for.20development.20without.20sudo.20rights
for more context.

<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
2024-05-30 16:03:55 +02:00