To start this script is running it a Github workflow, using shell bash, yaml truncated for readability. I've tried a number of things to make it work as multiline, so I can have comments.
set -x
set -e
AWK_SOURCE=$( cat <<- AWK
'
{
if ( $1 !~ /delete/ # ensure we are not trying to process deleted files
&& $4 !~ /theme.puml|config.puml/ # do not try to process our theme or custom config
&& $4 ~ /.puml/ ) # only process puml files
{ printf "%s ", $4 } # only print the file name and strip newlines for spaces
}
END { print "" } # ensure we do print a newline at the end
'
AWK
)
GIT_OUTPUT=`git diff-tree -r --no-commit-id --summary ${GITHUB_SHA}`
AWK_OUPUT=`echo $GIT_OUTPUT | awk -F' ' $AWK_SOURCE`
echo "::set-output name=files::$GIT_OUTPUT"
set +e
set +x
this is my current error
If I run it as a single line, it works fine
git diff-tree -r --no-commit-id --summary HEAD | awk -F' ' '{ if ( $1 !~ /delete/ && $4 !~ /theme.puml|config.puml/ && $4 ~ /.puml/ ) { printf "%s ", $4 } } END { print "" }'
this is the output/error I'm currently getting, I've gotten different ones.
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
+ set -e
++ cat
+ AWK_SOURCE=''\''
{
if ( !~ /delete/ # ensure we are not trying to process deleted files
&& !~ /theme.puml|config.puml/ # do not try to process our theme or custom config
&& ~ /.puml/ ) # only process puml files
{ printf "%s ", } # only print the file name and strip newlines for spaces
}
END { print "" } # ensure we do print a newline at the end
'\'''
++ git diff-tree -r --no-commit-id --summary 6c72c8a8dabf19ae2439ee506b9a4a636027193e
+ GIT_OUTPUT=' create mode 100644 .config/plantuml/config.puml
create mode 100644 .config/plantuml/theme.puml
delete mode 100644 config.puml
create mode 100644 docs/README.md
create mode 100644 docs/domain-model/README.md
create mode 100644 docs/domain-model/user.md
create mode 100644 docs/domain-model/user.puml
delete mode 100644 theme.puml
delete mode 100644 user.puml
delete mode 100644 user.svg'
++ echo create mode 100644 .config/plantuml/config.puml create mode 100644 .config/plantuml/theme.puml delete mode 100644 config.puml create mode 100644 docs/README.md create mode 100644 docs/domain-model/README.md create mode 100644 docs/domain-model/user.md create mode 100644 docs/domain-model/user.puml delete mode 100644 theme.puml delete mode 100644 user.puml delete mode 100644 user.svg
++ awk '-F ' \' '{' if '(' '!~' /delete/ '#' ensure we are not trying to process deleted files '&&' '!~' '/theme.puml|config.puml/' '#' do not try to process our theme or custom config '&&' '~' /.puml/ ')' '#' only process puml files '{' printf '"%s' '",' '}' '#' only print the file name and strip newlines for spaces '}' END '{' print '""' '}' '#' ensure we do print a newline at the end \'
awk: cmd. line:1: '
awk: cmd. line:1: ^ invalid char ''' in expression
+ AWK_OUPUT=
how can I retain my multiline awk with comments?