Giter Club home page Giter Club logo

Comments (11)

anki-code avatar anki-code commented on July 22, 2024 1

Hey! Nice catch! Thanks!

Workaround:

xonsh --no-rc
$f = p'/tmp/file.tmp'
echo 'abc' > $f

from xonsh.

Kossak-esky avatar Kossak-esky commented on July 22, 2024 1

Thank you very much for workaround and for this awesome shell!

from xonsh.

anki-code avatar anki-code commented on July 22, 2024

@Kossak-esky I made the fix. Please test:

xpip install -U --force-reinstall git+https://github.com/xonsh/xonsh@fix_redirect_to_subst
# restart xonsh
f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat @(f)
# abc

from xonsh.

Kossak-esky avatar Kossak-esky commented on July 22, 2024

It works, except cat < @(f) but I don't need this one (just tested it out of curiosity) and I understand it's not supported yet anyway.
Thank you!

from xonsh.

anki-code avatar anki-code commented on July 22, 2024

This works as well:

f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)
# abc

from xonsh.

Kossak-esky avatar Kossak-esky commented on July 22, 2024

ok, it turns out it doesn't work when I have coreutils xontrib enabled.

This works:

kossak@lman3 ~ @ xonsh@fix2 --no-rc
kossak@lman3 ~ @ f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)

abc

But when I create .xonshrc with body:

from xonsh.xontribs import xontribs_load

xontribs = [
    'coreutils',
]

xontribs_load(xontribs)

I get error:

kossak@lman3 ~ @ xonsh@fix2
kossak@lman3 ~ @ f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)

abc
xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
OSError: [Errno 9] Bad file descriptor

from xonsh.

Kossak-esky avatar Kossak-esky commented on July 22, 2024

With traceback:

kossak@lman3 ~ @ f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)

abc
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/home/kossak/.local/pipx/venvs/xonsh@fix2/lib/python3.9/site-packages/xonsh/built_ins.py", line 211, in subproc_captured_hiddenobject
    return xonsh.procs.specs.run_subproc(cmds, captured="hiddenobject", envs=envs)
  File "/home/kossak/.local/pipx/venvs/xonsh@fix2/lib/python3.9/site-packages/xonsh/procs/specs.py", line 957, in run_subproc
    return _run_specs(specs, cmds)
  File "/home/kossak/.local/pipx/venvs/xonsh@fix2/lib/python3.9/site-packages/xonsh/procs/specs.py", line 999, in _run_specs
    cp.end()
  File "/home/kossak/.local/pipx/venvs/xonsh@fix2/lib/python3.9/site-packages/xonsh/procs/pipelines.py", line 465, in end
    self._end(tee_output=tee_output)
  File "/home/kossak/.local/pipx/venvs/xonsh@fix2/lib/python3.9/site-packages/xonsh/procs/pipelines.py", line 478, in _end
    self._set_input()
  File "/home/kossak/.local/pipx/venvs/xonsh@fix2/lib/python3.9/site-packages/xonsh/procs/pipelines.py", line 576, in _set_input
    stdin.seek(0)
OSError: [Errno 9] Bad file descriptor

from xonsh.

anki-code avatar anki-code commented on July 22, 2024

It's fixed in the PR, just update - #5420 (comment)

from xonsh.

Kossak-esky avatar Kossak-esky commented on July 22, 2024

I did update it, but somehow it still doesn't work when I have coreutils loaded. Without coreutils it works fine.

[kossak@lman3 ~]$ xonsh@fix2
kossak@lman3 ~ @ xpip install -U --force-reinstall git+https://github.com/xonsh/xonsh@fix_redirect_to_subst
Collecting git+https://github.com/xonsh/xonsh@fix_redirect_to_subst
  Cloning https://github.com/xonsh/xonsh (to revision fix_redirect_to_subst) to /tmp/pip-req-build-b5arx8xv
  Running command git clone --filter=blob:none --quiet https://github.com/xonsh/xonsh /tmp/pip-req-build-b5arx8xv
  Running command git checkout -b fix_redirect_to_subst --track origin/fix_redirect_to_subst
  Switched to a new branch 'fix_redirect_to_subst'
  branch 'fix_redirect_to_subst' set up to track 'origin/fix_redirect_to_subst'.
  Resolved https://github.com/xonsh/xonsh to commit e4a6f4f75720203a5df71484f12fcbb997d0b052
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: xonsh
  Building wheel for xonsh (pyproject.toml) ... done
  Created wheel for xonsh: filename=xonsh-0.16.0-py39-none-any.whl size=618295 sha256=2c458fa6bb7bb57eca07b399be8fc287b8dd78d6b2505778f18041531e6c338c
  Stored in directory: /tmp/pip-ephem-wheel-cache-6lmd98_2/wheels/a2/ae/ce/309e0bc4c48c4f47153e136a2f071614cb1db1ec4563533df3
Successfully built xonsh
Installing collected packages: xonsh
  Attempting uninstall: xonsh
    Found existing installation: xonsh 0.16.0
    Uninstalling xonsh-0.16.0:
      Successfully uninstalled xonsh-0.16.0
Successfully installed xonsh-0.16.0
kossak@lman3 ~ @ xonsh@fix2
kossak@lman3 ~ @ xonfig
+-----------------------------+------------------------------------------------+
| xonsh                       | 0.16.0.dev114                                  |
| Git SHA                     | e4a6f4f7                                       |
| Commit Date                 | May 16 15:43:13 2024                           |
| Python                      | 3.9.16                                         |
| PLY                         | 3.11                                           |
| have readline               | True                                           |
| prompt toolkit              | 3.0.43                                         |
| shell type                  | prompt_toolkit                                 |
| history backend             | json                                           |
| pygments                    | 2.18.0                                         |
| on posix                    | True                                           |
| on linux                    | True                                           |
| distro                      | unknown                                        |
| on wsl                      | False                                          |
| on darwin                   | False                                          |
| on windows                  | False                                          |
| on cygwin                   | False                                          |
| on msys2                    | False                                          |
| is superuser                | False                                          |
| default encoding            | utf-8                                          |
| xonsh encoding              | utf-8                                          |
| encoding errors             | surrogateescape                                |
| xontrib 1                   | argcomplete                                    |
| xontrib 2                   | coreutils                                      |
| xontrib 3                   | navi                                           |
| xontrib 4                   | abbrevs                                        |
| xontrib 5                   | fzf-widgets                                    |
| xontrib 6                   | vox                                            |
| xontrib 7                   | voxapi                                         |
| RC file 1                   | /home/kossak/.xonshrc                          |
| RC file 2                   | /home/kossak/.config/xonsh/rc.d/asdf.xsh       |
| RC file 3                   | /home/kossak/.config/xonsh/rc.d/cdf.xsh        |
| RC file 4                   | /home/kossak/.config/xonsh/rc.d/gcp.xsh        |
| RC file 5                   | /home/kossak/.config/xonsh/rc.d/kubernetes.xsh |
| RC file 6                   | /home/kossak/.config/xonsh/rc.d/local_all.xsh  |
| RC file 7                   | /home/kossak/.config/xonsh/rc.d/local_home.xsh |
| RC file 8                   | /home/kossak/.config/xonsh/rc.d/local_work.xsh |
| RC file 9                   | /home/kossak/.config/xonsh/rc.d/ssh.xsh        |
| UPDATE_OS_ENVIRON           | False                                          |
| XONSH_CAPTURE_ALWAYS        | False                                          |
| XONSH_SUBPROC_OUTPUT_FORMAT | stream_lines                                   |
| THREAD_SUBPROCS             | True                                           |
| XONSH_CACHE_SCRIPTS         | True                                           |
+-----------------------------+------------------------------------------------+
kossak@lman3 ~ @ f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)
 
abc
xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
OSError: [Errno 9] Bad file descriptor
kossak@lman3 ~ @ xonsh@fix2 --no-rc
kossak@lman3 ~ @ f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)
 
abc
kossak@lman3 ~ @

from xonsh.

Kossak-esky avatar Kossak-esky commented on July 22, 2024

I tried clean installation, that shows that loading coreutils break things:

[kossak@lman3 ~]$ pipx install --python /home/kossak/.asdf/installs/python/3.9.16/bin/python --suffix=@fix3 'git+https://github.com/xonsh/xonsh@fix_redirect_to_subst'
  installed package xonsh 0.16.0 (xonsh@fix3), installed using Python 3.9.16
  These apps are now globally available
    - xonsh-cat@fix3
    - xonsh-uname@fix3
    - xonsh-uptime@fix3
    - xonsh@fix3
done! ✨ 🌟 ✨
[kossak@lman3 ~]$ xonsh@fix3 --no-rc
kossak@lman3 ~ @ f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)
abc
kossak@lman3 ~ @ xontrib list
coreutils  not-loaded
kossak@lman3 ~ @ xontrib load coreutils
kossak@lman3 ~ @ xontrib list
coreutils  loaded      manual
kossak@lman3 ~ @ f = p'/tmp/file.tmp'
echo 'abc' > @(f)
cat < @(f)
abc
xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
OSError: [Errno 9] Bad file descriptor
kossak@lman3 ~ @ 

from xonsh.

anki-code avatar anki-code commented on July 22, 2024

"Bad file descriptor" looks like #4792. Thank you for reporting. Feel free to create separate issue about coreutils if it's not 4792.

from xonsh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.