tree-sitter-bash icon indicating copy to clipboard operation
tree-sitter-bash copied to clipboard

awk script breaks if-then-fi highlighting

Open Frederick888 opened this issue 3 months ago • 0 comments

I have a script that configures some negative Git fetch refspecs for me:

#!/usr/bin/env bash

set -eo pipefail
shopt -s inherit_errexit

if ! rg -xF '^refs/heads/*-deploy' < <(git config --get-all remote.origin.fetch) >/dev/null &&
    rg -- '-deploy$' < <(git branch -r -l) >/dev/null; then
    git config --add remote.origin.fetch '^refs/heads/*-deploy'
    git branch -lr | awk '$1 ~ /-deploy$/ { printf "%s%s", $1, "\0" }' | xargs -0 -- git branch -r -d
fi

if ! rg -xF '^refs/tags/*-deploy' < <(git config --get-all remote.origin.fetch) >/dev/null &&
    rg -- '-deploy$' < <(git tag -l) >/dev/null; then
    git config --add remote.origin.fetch '^refs/tags/*-deploy'
    git tag -l | rg -- '-deploy$' | tr '\n' '\0' | xargs -0 -- git tag -d
fi

The awk '$1 ~ /-deploy$/ { printf "%s%s", $1, "\0" }' somehow breaks if-then-fi highlighting: Image

If I remove the awk command, it becomes normal: Image

The original script is correctly highlighted if I disable treesitter highlighting: Image

Frederick888 avatar Oct 03 '25 01:10 Frederick888