[Git][security-tracker-team/security-tracker][gen-dsa-no-color] gen-DSA: switch to getopt, add --no-color option
Sebastien Delafond (@seb)
seb at debian.org
Tue Feb 17 12:47:01 GMT 2026
Sebastien Delafond pushed to branch gen-dsa-no-color at Debian Security Tracker / security-tracker
Commits:
e8473725 by Sébastien Delafond at 2026-02-17T13:46:37+01:00
gen-DSA: switch to getopt, add --no-color option
- - - - -
1 changed file:
- bin/gen-DSA
Changes:
=====================================
bin/gen-DSA
=====================================
@@ -52,37 +52,56 @@ export LC_ALL=C
exit 1
}
-[ $# -ge 1 ] || {
- echo "usage: $0 [--save] [--embargoed|--unembargo] [$IDMODE] package[.changes] [regression] [cve(s) [bugnumber(s)]] "
+usage() {
+ echo "usage: $0 [--save] [--embargoed|--unembargo] [--no-color] [$IDMODE] package[.changes] [regression] [cve(s) [bugnumber(s)]] "
echo " '$IDMODE' is the $IDMODE number, required when issuing a revision"
echo " 'cve(s)' and 'bugnumber(s)' can be passed in any order but"
echo " always AFTER the description"
- echo ""
+ echo
echo " When specifying package.changes the package name, version, additional bug(s) and cve(s)"
echo " are parsed from the .changes file."
- echo ""
+ echo
echo " If it doesn't like your bug number, prefix it with # and report"
- exit 1
-} >&2
+}
-save=false
-if [ "$1" = "--save" ]; then
- save=true
- shift
-fi
+ARGS=$(getopt --options "e,h,n,s,u" --longoptions "embargoed,help,no-color,save,unembargo" -- "$@" || { usage >&2 ; exit 1 ;})
-embargoed=false
-if [ "$1" = "--embargoed" ]; then
- embargoed=true
- shift
-fi
+eval set -- "$ARGS"
+save=false
+embargoed=false
unembargo=false
-if [ "$1" = "--unembargo" ]; then
- unembargo=true
- shift
- set -- "$1"
-fi
+color=true
+while true ; do
+ case "$1" in
+ -e|--embargoed)
+ embargoed=true
+ shift
+ continue ;;
+ -h|--help)
+ usage >&2
+ exit 0 ;;
+ -n|--no-color)
+ color=false
+ shift
+ continue ;;
+ -s|--save)
+ save=true
+ shift
+ continue ;;
+ -u|--unembargo)
+ unembargo=true
+ shift
+ continue ;;
+ --)
+ shift
+ break ;;
+ *)
+ echo $1
+ echo "internal error" >&1
+ exit 1 ;;
+ esac
+done
toupper() {
printf '%s' "$1" | tr '[:lower:]' '[:upper:]'
@@ -149,7 +168,7 @@ setvar() {
sed -i "s=\$$var=$value=g" "$tmpf"
}
-if command -v tput >/dev/null; then
+if $color && [ -z "$NO_COLOR" ] && command -v tput >/dev/null ; then
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
MAGENTA=$(tput setaf 5)
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/commit/e8473725b318eb53e0f80b2955a0bf28cf978683
--
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/commit/e8473725b318eb53e0f80b2955a0bf28cf978683
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-security-tracker-commits/attachments/20260217/a71c6ff5/attachment-0001.htm>
More information about the debian-security-tracker-commits
mailing list