我想使用此
“ 2> >(grep -v警告1>& 2)
当我使用鱼壳时,我确实发现该命令必须成为 yarn install install 2> “>(grep -v警告1>& 2)
要避免语法错误
,但是在我想运行 yarn运行post intstall -force
之后
,我的命令变成纱线安装2> “>(grep -v警告1>& 2)”&&纱线运行后插图 - force
似乎不起作用, YARN RUN POSTENSTALL -FORCE
并未真正运行。命令在纱线安装后立即完成
完成。
有什么想法如何解决?
更新:
我还希望该脚本在Bash中运行,因为这不仅会在我的本地开发机上执行,而且还将在没有安装鱼壳的CD/CI上执行。
I want to ignore yarn errors using this method
yarn install 2> >(grep -v warning 1>&2)
As I am using fish shell I did figure out that this command has to become yarn install 2> ">(grep -v warning 1>&2)"
to avoid a syntax error
However after one I want to run yarn run postinstall --force
So my command became yarn install 2> ">(grep -v warning 1>&2)" && yarn run postinstall --force
however it seems does not work, yarn run postinstall --force
does not really runs. Command finishes right afteryarn install
finishes.
Any ideas how to fix?
UPDATE:
I also want that script to run in bash because this going to execute not just on my local dev machine but also on CD/CI that does not have fish-shell installed..
发布评论
评论(1)
编辑:这个问题最初被标记为“鱼”,因此此答案假设您想使用鱼来运行脚本。
这有点笨拙。它将
纱线安装的stderr管输入过程替换(
>()
语法,就像其<()表弟)。这将创建一个临时文件,然后将其连接到
grep -v
的stdin,然后将其输出重定向到stderr。效果是对STDER进行了过滤,并删除包含“警告”的任何线路。的确,原因是它的bash中很尴尬,但不是stderr - 请参见我如何管道stderr,而不是stdout? - 这是 https://stackoverflow.com/ A/15936384/3150338 。
在FISH中,您只需用
2> |
将STDER置于stderr:例如,
请参阅stderr上的“错误”,以及“输出”和“警告,但在Stdout上”。
EDIT: The question was originally tagged as "fish", so this answer assumes you'd want to use fish to run the script.
This is a bit of an awkward idiom. It pipes the stderr of
yarn install
into a process substitution (the>()
syntax, which is like the reverse of its<()
cousin). This creates a temporary file that it will then connect togrep -v
's stdin, which will then get its output redirected to stderr again. The effect is that stderr is filtered and any line containing "warning" is removed.Really, the reason for this is that it is awkward in bash to pipe stderr but not stdout - see How can I pipe stderr, and not stdout? - this is https://stackoverflow.com/a/15936384/3150338.
In fish, you can just pipe stderr with
2>|
:See e.g.
This will print "error" on stderr, and "output" and "warning but on stdout" on stdout.