Piping in an alias support #5296
Answered
by
anki-code
putrasattvika
asked this question in
Q&A
-
In zsh you can configure an alias like this: alias myalias='yq -o json | jq -c .' And (IIUIC) a command like However, in xonsh it seems that we can't use pipes in an alias: # Executing using the alias seems to break the input coming to jq
aliases['myalias'] = 'yq -o json | jq -c .'
$XONSH_TRACE_SUBPROC=True
cat file.yml | myalias
# TRACE SUBPROC: (['cat', 'file.yml'], '|', ['myalias']), captured=hiddenobject
# TRACE SUBPROC: (['yq', '-o', 'json'], '|', ['jq', '-c', '.']), captured=hiddenobject
# parse error: Invalid numeric literal at line 1, column 6
# Executing without using the alias works as expected
cat file.yml | yq -o json | jq -c .
# TRACE SUBPROC: (['cat', 'file.yml'], '|', ['yq', '-o', 'json'], '|', ['jq', '-c', '.']), captured=hiddenobject
# {"collections":[{"name":"kubernetes.core","version":"2.4.0","source":"https://galaxy.ansible.com"}]} Is this behavior expected? |
Beta Was this translation helpful? Give feedback.
Answered by
anki-code
Apr 2, 2024
Replies: 1 comment 1 reply
-
This looks like a new feature - alias expanding. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
putrasattvika
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks like a new feature - alias expanding.