Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piping to ppl does not return on Mac #6

Open
amitkot opened this issue Feb 28, 2022 · 7 comments
Open

Piping to ppl does not return on Mac #6

amitkot opened this issue Feb 28, 2022 · 7 comments
Labels

Comments

@amitkot
Copy link

amitkot commented Feb 28, 2022

Trying pipeliner on a Mac and the command never returns.

This does not return:

> echo 1 | ppl 'line'

Neither does this:

> echo 1 | ppl 'line' | cat
> xonfig
+------------------+----------------------+
| xonsh            | 0.10.1               |
| Git SHA          | 337cf25a             |
| Commit Date      | Nov 17 15:37:41 2021 |
| Python           | 3.9.9                |
| PLY              | 3.11                 |
| have readline    | True                 |
| prompt toolkit   | 3.0.24               |
| shell type       | prompt_toolkit       |
| history backend  | json                 |
| pygments         | 2.11.2               |
| on posix         | True                 |
| on linux         | False                |
| on darwin        | True                 |
| on windows       | False                |
| on cygwin        | False                |
| on msys2         | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
| on jupyter       | True                 |
| jupyter kernel   | None                 |
| xontrib 1        | bashisms             |
| xontrib 2        | coreutils            |
| xontrib 3        | jedi                 |
| xontrib 4        | pipeliner            |
| xontrib 5        | pyenv                |
| xontrib 6        | sh                   |
| xontrib 7        | vox                  |
| xontrib 8        | vox_tabcomplete      |
| xontrib 9        | voxapi               |
+------------------+----------------------+
@anki-code anki-code changed the title Piping to pl does not return Piping to ppl does not return Feb 28, 2022
@anki-code
Copy link
Owner

@anki-code
Copy link
Owner

You can use pl instead of ppl on mac.

@amitkot
Copy link
Author

amitkot commented Feb 28, 2022

Sadly these do not work as well:

> echo 1 | pl 'line'
> echo 1 | pl 'line' | cat

@amitkot
Copy link
Author

amitkot commented Feb 28, 2022

@anki-code Is there a "debug" flag I can run with to see why it freezes?

@amitkot
Copy link
Author

amitkot commented Mar 20, 2022

@anki-code I really like this idea, but this does not work for me. Any idea how to make it work?

@anki-code
Copy link
Owner

May be this is also related to $XONSH_CAPTURE_ALWAYS.
Try to set $XONSH_CAPTURE_ALWAYS = True before usage.

@anki-code
Copy link
Owner

anki-code commented Mar 21, 2022

@amitkot pl is a callable alias:

def _pl(args, stdin, stdout):
err = False
if len(args) == 0:
print('Error: Python code not found', file=sys.stderr)
err = True
if err:
print('Usage: <command> | <command> | ... | pl "<Python code>"', file=sys.stderr)
print('Example: echo "123" | pl "line[::-1]"', file=sys.stderr)
return
fn = eval('lambda line, num:'+args[0], __xonsh__.ctx)
if stdin is None:
try:
print(fn(None, 0))
except:
print_color('{YELLOW}' + str(traceback.format_exc()), file=sys.stderr)
return
num = 0
for line in stdin.readlines():
try:
res = fn(line.rstrip(os.linesep), num)
except:
print_color('{YELLOW}' + f'Error line {num+1}: {line}', file=sys.stderr)
print_color('{YELLOW}' + str(traceback.format_exc()), file=sys.stderr)
return
num += 1
if res is not None:
print(res, file=stdout, flush=True)

So as a good start you can just debug this function on mac.

@anki-code anki-code changed the title Piping to ppl does not return Piping to ppl does not return on Mac Mar 21, 2022
@anki-code anki-code added the mac label Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants