admin管理员组文章数量:1122832
Ok, so I have been using wp plugin update --all
in the past with a tee command. There has been no problem in the past, but after I ran an update on my system, everytime I run the command through a pipe, the formatting is messed up.
So this is the gist of the command used:
wp plugin update --all|awk '/Success/,EOF'| tee >(convert -font Courier -pointsize 14 label:@- img.png)
Previously it would produce a flawless output:
However, now when I pipe, even if I leave out the convert command, say something like this: `wp plugin update --all | tee test.txt' the output is messed up....
or
Has anyone got any ideas....driving me a bit crazy...
Ok, so I have been using wp plugin update --all
in the past with a tee command. There has been no problem in the past, but after I ran an update on my system, everytime I run the command through a pipe, the formatting is messed up.
So this is the gist of the command used:
wp plugin update --all|awk '/Success/,EOF'| tee >(convert -font Courier -pointsize 14 label:@- img.png)
Previously it would produce a flawless output:
However, now when I pipe, even if I leave out the convert command, say something like this: `wp plugin update --all | tee test.txt' the output is messed up....
or
Has anyone got any ideas....driving me a bit crazy...
Share Improve this question asked Apr 15, 2021 at 13:53 Neural_oDNeural_oD 232 bronze badges2 Answers
Reset to default 1WP CLI needs to know some things about the terminal it's running in to format the table, aka the TTY.
But when you pipe, there is no TTY!
But you can trick it into thinking there is if you use this bash function:
faketty() {
0</dev/null script --quiet --flush --return --command "$(printf "%q " "$@")" /dev/null
}
then you can run WP CLI commands and it will think it’s running in an interactive shell, not a pipe, e.g.:
faketty wp post list | more
You can use the SHELL_PIPE
ENV variable to preserve the ascii format, according to the WP-CLI docs:
To enable ASCII formatting even when the shell is piped, use the ENV variable SHELL_PIPE=0.
For a single WP-CLI command this might be sufficient, e.g.:
( SHELL_PIPE=0 wp plugin list > list.txt )
or
( SHELL_PIPE=0 wp plugin list | less )
to preserve the ascii table format when piping. This answer is helpful regarding subshell.
Ensure there is no semicolon after the environment variable, so it is actually applied to the command.
The parenthesis for running the command in a sub-shell are optional.
本文标签: wp cliFormatting messed up when piping wp commands
版权声明:本文标题:wp cli - Formatting messed up when piping wp commands 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736296272a1929755.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论