mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
chore: Use lib_getopt for all hooks and some style tweaks (#137)
This commit is contained in:
parent
0c5cbb380b
commit
1d8af371d4
4 changed files with 99 additions and 1075 deletions
12
lib_getopt
12
lib_getopt
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
getopt() {
|
||||
# pure-getopt, a drop-in replacement for GNU getopt in pure Bash.
|
||||
# version 1.4.3
|
||||
# version 1.4.4
|
||||
#
|
||||
# Copyright 2012-2018 Aron Griffis <aron@scampersand.com>
|
||||
# Copyright 2012-2020 Aron Griffis <aron@scampersand.com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
|
|
@ -37,7 +37,7 @@ getopt() {
|
|||
# "options -- parameters" on stdout.
|
||||
|
||||
declare parsed status
|
||||
declare short long name flags
|
||||
declare short long='' name flags=''
|
||||
declare have_short=false
|
||||
|
||||
# Synopsis from getopt man-page:
|
||||
|
|
@ -122,7 +122,7 @@ getopt() {
|
|||
return 4 ;;
|
||||
|
||||
(-V|--version)
|
||||
echo "pure-getopt 1.4.3"
|
||||
echo "pure-getopt 1.4.4"
|
||||
return 0 ;;
|
||||
|
||||
(--)
|
||||
|
|
@ -367,7 +367,7 @@ getopt() {
|
|||
# status 2.) If there is no match at all, prints a message on stderr
|
||||
# and returns 2.
|
||||
declare a q="$1"
|
||||
declare -a matches
|
||||
declare -a matches=()
|
||||
shift
|
||||
for a; do
|
||||
if [[ $q == "$a" ]]; then
|
||||
|
|
@ -410,7 +410,7 @@ getopt() {
|
|||
|
||||
_getopt_quote() {
|
||||
# Quotes arguments with single quotes, escaping inner single quotes
|
||||
declare s space q=\'
|
||||
declare s space='' q=\'
|
||||
for s; do
|
||||
printf "$space'%s'" "${s//$q/$q\\$q$q}"
|
||||
space=' '
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue