tree-sitter-bash
tree-sitter-bash copied to clipboard
awk script breaks if-then-fi highlighting
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:
If I remove the awk command, it becomes normal:
The original script is correctly highlighted if I disable treesitter highlighting: