English 中文(简体)
azure dev opseck Branch name for (in a bash)
原标题:azure dev ops check branch name for ( in a bash

I need to check a branch name for the ( sign. E.g. we have $(Build.SourceBranch) = "test(1)" . When I try to call my command "myCommand $(Build.SourceBranch)" it fails with something like /agent/_work/_temp/653563be-e452-4f06-a7a8-276aad30c025.sh: line 12: syntax error near unexpected token `( where line 12 is the line in the bash with myCommand.

还将由大韩民国在篮子里检查,分行名称不包含“(......)”,但当我试图核对该名称时,会发生yn误:

<编码> 重复“Branch:$(Build.SourceBranch)”和(Build.SourceBranch) gr-i()

将按原样印刷:

command: test(1) /agent/_work/_temp/653563be-e452-4f06-a7a8-276aad30c025.sh: line 12: syntax error near unexpected token ( ` In my local bash the above grep command would just return the branch name. Any ideas on how I could exit the bash without a syntax error in this case would be very helpful.

I not only tried echo also if [ $(Build.SourceBranch) == "test(1)"] then echo "test " fi with syntax error, tried also to convert the "(" in the string to some other string but unfortunately failed. Eckard.

问题回答

我可以用以下的yam子管理。

The branch name is test(1). The value of $(Build.SourceBranch) is refs/heads/test(1).

trigger:
- none

pool:
  vmImage: ubuntu-latest

steps:
- bash: |
     echo "sourceBranch: $(Build.SourceBranch)"
     echo "$(Build.SourceBranch)" | grep -i  ( 

     if [[ "$(Build.SourceBranch)" == *"test(1)" ]]; then 
     echo "test " 
     fi

  displayName:  Run a multi-line script 

结果:

“在座的影像描述”/</a





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...

热门标签