La regola del progetto è «codice e commenti in inglese; interfaccia, documenti e messaggi in italiano», e gli script di .gitea/ (script e flussi), di installer/ e docker/entrypoint.sh avevano ancora i commenti in italiano (decisione di Alberto del 29 novembre 2026). Cambiano solo i commenti: i messaggi che una persona legge (echo, ::warning::, ::error::, nomi dei passi, note della release) restano in italiano e nessun comando cambia. I programmi awk e gli script finti delle prove erano già in inglese. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.7 KiB
Bash
45 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
# JSON for the CI steps, without third-party programs (no jq, no Node; decision of Alberto of 18 November 2026):
|
|
# reads with json.awk and json-campi.awk, writes strings with json-stringa.awk. POSIX awk, no network.
|
|
#
|
|
# json.sh campi <percorso> <campo,campo...> <file.json>... for each object at that place, one line with the fields
|
|
# separated by a TAB (json-campi.awk): empty path for
|
|
# the root object, «*» for every element of a list,
|
|
# for example «Results/*/Vulnerabilities/*»
|
|
# json.sh stringa <testo> the text as a JSON string, quotes included
|
|
#
|
|
# A file that is not valid JSON: no output, the reason on stderr, exit status 2. PipelineTests tests it.
|
|
set -euo pipefail
|
|
|
|
qui="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
export LC_ALL=C
|
|
uso() {
|
|
echo "Uso: json.sh campi <percorso> <campo,campo...> <file.json>... | stringa <testo>" >&2
|
|
exit 2
|
|
}
|
|
|
|
modo="${1:-}"
|
|
(($# > 0)) && shift
|
|
case "$modo" in
|
|
campi)
|
|
(($# >= 3)) || uso
|
|
percorso="$1" campi="$2"
|
|
shift 2
|
|
nome='[A-Za-z_][A-Za-z0-9_.-]*'
|
|
passo='([A-Za-z0-9_.-]+|[*])'
|
|
[[ "$campi" =~ ^$nome(,$nome)*$ ]] || uso
|
|
[[ -z "$percorso" || "$percorso" =~ ^$passo(/$passo)*$ ]] || uso
|
|
for file in "$@"; do
|
|
[[ -f "$file" ]] || { echo "json.sh: manca il file $file" >&2; exit 2; }
|
|
done
|
|
exec awk -v percorso="$percorso" -v campi="$campi" -f "$qui/json.awk" -f "$qui/json-campi.awk" "$@"
|
|
;;
|
|
stringa)
|
|
(($# == 1)) || uso
|
|
printf '%s' "$1" | awk -f "$qui/json-stringa.awk"
|
|
;;
|
|
*)
|
|
uso
|
|
;;
|
|
esac
|