chore: Use lib_getopt for all hooks and some style tweaks (#137)

This commit is contained in:
Robin Bowes 2020-08-27 20:55:28 +01:00 committed by GitHub
commit 1d8af371d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 99 additions and 1075 deletions

View file

@ -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=' '