Git Product home page Git Product logo

Comments (3)

anki-code avatar anki-code commented on June 25, 2024 1

@yaxollum thank you for the fast answer! Hmmm, okay, I will revert the revert - #5475 :)

from xonsh.

anki-code avatar anki-code commented on June 25, 2024

Hi @yaxollum!
I found that the commit that did breaking changes:

Please take a look and add more tests (I'm using this for test). Thanks!

Also I see that command echo 1 > file becomes ['echo', '1', ('>',), 'file'] in _flatten_cmd_redirects(cmd) maybe this is the cause of None error.

I'm using this to find regress:

# Checkout every commit and test command

$RAISE_SUBPROC_ERROR=True
mkdir -p /tmp/xonsh_dev
cd /tmp/xonsh_dev
git clone https://github.com/xonsh/xonsh
cd xonsh

xonsh_bin = ["python", "-m", "xonsh", "--no-rc"]
commits = [(c.split(' ', 1)[0], c.split(' ', 1)[1]) for c in $(git log '43c9aaf..' --reverse --oneline)]
for hash, descr in commits:
    printx(f"{{YELLOW}}{hash} {descr[:80]!r}{{RESET}}")
    _ = $(git checkout -f @(hash))
    @(xonsh_bin) -V
    # Check regress
    @(xonsh_bin) -c "echo 123 > @('/tmp/file')"


# 08ac0d97 'Fix parsing of redirect tokens (#5322)'
# Previous HEAD position was 7461c507 Fix incorrect IOREDIRECT tokens in Python mode (#5013)
# HEAD is now at 08ac0d97 Fix parsing of redirect tokens (#5322)
# xonsh/0.15.1
# Traceback (most recent call last):
#   File "/private/tmp/xonsh_dev/xonsh/xonsh/procs/specs.py", line 179, in safe_open
#     return open(fname, mode, buffering=buffering)
#            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# TypeError: expected str, bytes or os.PathLike object, not NoneType

from xonsh.

yaxollum avatar yaxollum commented on June 25, 2024

Hi @anki-code , thanks for investigating this issue! The reason why the @() operator outputs a list is that it can produce multiple arguments. For example:

echo @(['hello','world'])
# Output: hello world

echo @(['a','b'])@(['c','d'])
# Output: ac ad bc bd

I don't think it's possible to fix this issue in the parser because in some cases we only know the length of the list at runtime:

mylist = ['a']
echo hello > @(mylist) # should redirect output to file 'a'

mylist = ['a', 'b', 'c']
echo hello > @(mylist) # should produce an error since we cannot output to multiple files

Considering this, I think the fix that you provided in #5423 is probably the best solution.

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.