输出命令为空

编程入门 行业动态 更新时间:2024-10-10 13:17:35
本文介绍了输出命令为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Azure管道变量来为命令构造一组参数.我必须用于Azure管道的变量类型为宏格式(例如 $(var)),您可以在此处查看其详细信息: docs.microsoft/en-us/azure/devops/pipelines/process/variables?view = azure-devops&stab = yaml%2Cbatch#runtime-expression-syntax

I am using Azure pipelines variables to construct a set of parameters for a command. The type of variable I must use for Azure pipelines is in macro format (like $(var)), you can see the details of it here: docs.microsoft/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#runtime-expression-syntax

如果 $(var)不包含值,则不打印"nothing",而是打印 $(var)

If $(var) does not contain a value, instead of printing "nothing", it will print $(var)

当我运行命令并且未传递该值时,屏幕上会提示错误,提示未找到该命令.目前,这没什么大不了的,它不会出错我下面的命令集,但是我希望至少能抑制它.

When I run my command and that value isn't passed in, an error prompts on the screen that command was not found. At the moment it's not a big deal, it doesn't error my following set of commands, but I was hoping to suppress it at the very least.

VAR_TERRAFORMDESTROY="$(TERRAFORMDESTROY)" if [ ${#VAR_TERRAFORMDESTROY} -ge 1 ]; then VAR_TERRAFORMDESTROY="yes" else VAR_TERRAFORMDESTROY="no" fi

在日志输出中,它将打印/vsts/_work/_temp/4e426335-0930-4375-b05c-c4dbbcb38139.sh:第5行:TERRAFORMDESTROY:未找到命令

In the logs output it will print /vsts/_work/_temp/4e426335-0930-4375-b05c-c4dbbcb38139.sh: line 5: TERRAFORMDESTROY: command not found

我尝试了 VAR_TERRAFORMDESTROY =" $(TERRAFORMDESTROY)".>/dev/null 2>& 1 ,但是因为>/dev/null 2>& 1 不在方括号()内,它不会将结果输出为null.由于Azure YAML变量的工作原理,它不能放在方括号内.

I have tried VAR_TERRAFORMDESTROY="$(TERRAFORMDESTROY)" > /dev/null 2>&1, but because > /dev/null 2>&1 is not inside the brackets (), it will not output the result to null. And it cannot be inside the brackets due to how Azure YAML variables work.

请问有人可以建议抑制我找不到的命令输出吗?

Can anyone suggest anything to suppress the command not found output for me, please?

推荐答案

请问有人可以抑制我找不到的命令吗?

Can anyone suggest anything to suppress the command not found output for me, please?

禁止显示组错误消息

{ VAR_TERRAFORMDESTROY="$(TERRAFORMDESTROY)"; } > /dev/null 2>&1

更多推荐

输出命令为空

本文发布于:2023-10-27 23:58:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534905.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为空   命令

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!