Created
          August 14, 2024 09:16 
        
      - 
      
- 
        Save kiquenet/0cca459b9b1a9cbb5578689b49a16739 to your computer and use it in GitHub Desktop. 
    assign variables gets command not found
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function check_tag_exists() { | |
| local tag=$1 | |
| local return_var=$2 | |
| log_func_call ">" "${FUNCNAME[0]}" "${FUNCNAME[1]}" | |
| # Inicializamos la variable de retorno. | |
| local tag_found=1 | |
| local found=1 | |
| # Establece una trampa que se ejecuta cuando la función sale. | |
| #trap 'log_func_call "<" "${FUNCNAME[0]}" "${FUNCNAME[1]}"' RETURN | |
| git ls-remote --tags origin | while read -r line; do | |
| echo "Tag ${tag} en linea ${line}." >&1 | |
| if echo "$line" | grep -q "refs/tags/${tag}$"; then | |
| echo ">>>>>>> Tag ${tag} found." >&1 | |
| #tag_found=0 | |
| #eval $tag_found=0 fails | |
| #eval "${tag_found}"=0 fails ./templates/scripts/release_helpers.sh: line 135: 1=0: command not found | |
| found=0 | |
| echo ">>>>>>> tag_found ${tag_found}" >&1 | |
| break | |
| fi | |
| echo ">>>>>>> 1 tag_found ${tag_found}" >&1 | |
| done | |
| echo "******tag_found ${tag_found} ****" >&1 | |
| if [ "$tag_found" -eq "0" ]; then | |
| echo "******Tag ${tag} found****" >&1 | |
| eval $return_var=0 | |
| else | |
| echo "ELSE ******Tag ${tag} not found****" >&2 | |
| eval $return_var=1 | |
| fi | |
| eval $return_var=$found | |
| # Establece una trampa que se ejecuta cuando la función sale. | |
| trap 'log_func_call "< res $return_var" "${FUNCNAME[0]}" "${FUNCNAME[1]}"' RETURN | |
| } | |
| ALWAYS get value 1, why ? not works in while-do ? | |
| check_tag_exists "$releaseVersion" tag_exists | |
| echo "tag_exists ${tag_exists} value." | |
| if [ "$tag_exists" -eq 0 ]; then | |
| echo "La etiqueta ${releaseVersion} existe." | |
| else | |
| echo "La etiqueta ${releaseVersion} no existe." | |
| fi | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment