xonsh / xontrib-coreutils

Additional cross-platform core utilities that are implemented in xonsh.
2 stars 1 forks source link

pipes broken with coreutils xontrib #2

Open aspieln3r opened 2 years ago

aspieln3r commented 2 years ago

xonfig

``` # XONSH WEBCONFIG START $XONSH_COLOR_STYLE = 'monokai' $PROMPT = '{env_name}{BOLD_#6df797}{user}@{hostname}{CYAN} {cwd}{branch_color}{curr_branch: {}}{RESET} {BOLD_#7d8dff}{prompt_end}{RESET} ' xontrib load abbrevs argcomplete bashisms coreutils kitty pipeliner z # XONSH WEBCONFIG END $LS_COLORS='rs=0:di=01;36:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:' # Coloured man page support # using 'less' env vars (format is '\E[;m') $LESS_TERMCAP_mb = "\033[01;31m" # begin blinking $LESS_TERMCAP_md = "\033[01;31m" # begin bold $LESS_TERMCAP_me = "\033[0m" # end mode $LESS_TERMCAP_so = "\033[01;44;36m" # begin standout-mode (bottom of screen) $LESS_TERMCAP_se = "\033[0m" # end standout-mode $LESS_TERMCAP_us = "\033[00;36m" # begin underline $LESS_TERMCAP_ue = "\033[0m" # end underline # custom colors from xonsh.tools import register_custom_style mystyle = { "Token.PTK.AutoSuggestion" : "#c2961f", } register_custom_style("mystyle", mystyle, base="monokai") $XONSH_COLOR_STYLE="mystyle" # aliases aliases['la']='ls -al' aliases['ra']='ranger' aliases["mimeset"]="mimetype -d" aliases["rscp"]="rsync -ah --info=progress2" aliases["update"]="sudo pacman -Syu" aliases["remove"]="sudo pacman -Rns" aliases["pin"]="sudo pacman -S" aliases["cdh"]="cd ~/Home" aliases["vim"]="nvim" aliases["pamcan"]="pacman" aliases["nord"]="nordvpn" aliases["vimdiff"]="nvim -d" aliases["iconf"]="nvim ~/.config/i3/config" aliases["zconf"]="nvim ~/.zshrc" aliases["ip"]="ip -c" aliases["la"]="ls -alh" aliases["ll"]="ls -lh" aliases["rconf"]="vim ~/.config/ranger/rc.conf" aliases["copy"]="rsync -ah --info=progress2 " aliases["ra"]="ranger" #aliases["grep"]="grep --color" aliases["du"]="du -h" aliases["df"]="df -h" aliases["pgrep"]="pgrep -a" aliases["pkgsort"]="expac --timefmt='%Y-%m-%d %T' '%l\t%n'|sort -n" aliases["pinfo"]="yay -Si" aliases["psize"]="expac -sH M '%-30n %m' | sort -rhk 2 | head -30" aliases["clear2"]="sudo paccache -rk 2" aliases["pkglist"]="pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'" aliases["restart-plasma"]="plasmashell --replace > /dev/null 2>&1 & disown" aliases["restart-kwin"]="DISPLAY=:0 kwin_x11 --replace > /dev/null 2>&1 & disown" aliases["lln"]="ls -lhtr " aliases["llan"]="ls -alhtr" ```

Expected Behavior

piping just works like in other shells

Current Behavior

pipes work for some commands but hangs shell for others. ctrl z makes the job background and returns to zonsh. jobs return: [1]+ running: echo hai | grep hai (149404) fg doesnt do anything if grep but opens an empty window if it was a command piped to less and pressing q quits like in normal less window

Traceback (if applicable)

no traceback as shell hangs

Steps to Reproduce

following commands doesnt work cat /etc/resolv.conf | less echo hai | grep hai

following works ls | grep filename more textfile | grep string I'm using arch linux

> xonsh -V
xonsh/0.10.0

For community

⬇️ Please click the πŸ‘ reaction instead of leaving a +1 or πŸ‘ comment

aspieln3r commented 2 years ago

cat /etc/resolv.conf | more freezes shell completely. ctrl +z or c doesnt work

gforsyth commented 2 years ago

Hey @aspieln3r -- thanks for reporting! Can you try upgrading to 0.10.1? I'm also on arch and can't reproduce these hangs

aspieln3r commented 2 years ago

I'm already using latest on community. Will update once 0.10.1 hits repo

anki-code commented 2 years ago

hi @aspieln3r! I also can't reproduce this. Could you please run bash then run xonsh --no-rc and test the command. If it works test your RC-file line by line to catch the error.

aspieln3r commented 2 years ago

@anki-code I tried it and everything works well if I disable xontrib load coreutils. That also explains why I got issue with only cat and echo. Issue is present in 0.10.1 too

anki-code commented 2 years ago

@aspieln3r why you need coreutils xontrib on Arch? This xontrib mostly for Windows users.

aspieln3r commented 2 years ago

From https://xon.sh/xontribs.html#coreutils

In many cases, these may have a lower performance overhead than the posix command line utility with the same name. This is because these tools avoid the need for a full subprocess call. Additionally, these tools are cross-platform.

So I thought it wouldn't hurt using that.

Mic92 commented 2 years ago

I think this affects all aliases for this matter.

which ls | grep ls

also hangs.

Mic92 commented 2 years ago
❯ xonsh --no-rc

                                                               Welcome to the xonsh shell 0.12.4

                                                             ~ Tab completion in Alderaan places ~

# ...

joerg@turingmachine ~ master $ def command(args, stdin, stdout):
..............................     print("foo", file=stdout)
..............................
joerg@turingmachine ~ master $ aliases["command"] = command
joerg@turingmachine ~master $ del command
joerg@turingmachine ~master $ command | grep foo # this will hang until one presses `ctrl-c`
Mic92 commented 2 years ago

It seems that even pipeliner hangs for me:

turingmachine in dotfiles on ξ‚  master via 🐍 v3.9.12 via ❄️  impure (nix-shell)
❯ xontrib load pipeliner

turingmachine in dotfiles on ξ‚  master via 🐍 v3.9.12 via ❄️  impure (nix-shell)
❯ ls -1 / | pl "line + ' is here'" | head -n 3
yaxollum commented 1 year ago

@Mic92 Could you please try setting $THREAD_SUBPROCS=True and then running those commands?

Mic92 commented 1 year ago

Sorry. Stopped using xonsh.