Browse Source

Allow the password to start with a -.

In that case the options have to be terminated with a --.
In future this options should be added to all functions.
master
Georg Hopp 9 years ago
parent
commit
0c5dbbebf0
  1. 14
      accountmanager.sh

14
accountmanager.sh

@ -141,9 +141,10 @@ function amngrid() {
function amngrcrypt() {
local OPT OPTARG OPTIND PLAIN RECIPIENT
local OPTEND=0
local USAGE="$(printf "Usage: %s [-h] [-r recipient] password" "$0")"
while getopts hr: OPT
while getopts hr:- OPT
do
case $OPT in
r)
@ -151,10 +152,13 @@ function amngrcrypt() {
h)
echo "${USAGE}"
return 0;;
-)
OPTEND=1;;
?)
echo "${USAGE}"
return 1;;
esac
test ${OPTEND} -eq 1 && break
done
shift $(($OPTIND-1))
@ -201,13 +205,14 @@ function amngrgen() {
function amngradd() {
local OPT OPTARG OPTIND DESCRIPTION RECIPIENT DB
local OPTEND=0
local USAGE="$(cat <<-EOT
Usage: $0 [-h] [-d description] [-D dbfile] [-r recipient]
account [username [password]]
EOT
)"
while getopts d:D:hr: OPT
while getopts d:D:hr:- OPT
do
case $OPT in
d)
@ -219,10 +224,13 @@ function amngradd() {
h)
echo "${USAGE}"
return 0;;
-)
OPTEND=1;;
?)
echo "${USAGE}"
return 1;;
esac
test ${OPTEND} -eq 1 && break
done
shift $(($OPTIND-1))
@ -255,7 +263,7 @@ function amngradd() {
if [ "${3}" ]
then
PASSWORD="$(amngrcrypt -r "${RECIPIENT}" "${3}")"
PASSWORD="$(amngrcrypt -r "${RECIPIENT}" -- "${3}")"
else
PASSWORD="$(amngrgen -r "${RECIPIENT}")"
echo -n "${PASSWORD}" | gpg -dq | xclip -i

Loading…
Cancel
Save