Showing
2 changed files
with
13 additions
and
6 deletions
accountmanager.sh
100644 → 100755
@@ -382,13 +382,16 @@ function amngrgetolduser() { | @@ -382,13 +382,16 @@ function amngrgetolduser() { | ||
382 | 382 | ||
383 | function amngrgetpass() { | 383 | function amngrgetpass() { |
384 | local OPT OPTARG OPTIND DB | 384 | local OPT OPTARG OPTIND DB |
385 | - local USAGE="$(printf "Usage: %s [-h] [-D dbfile] account [state]" "$0")" | 385 | + local STDOUT=0 |
386 | + local USAGE="$(printf "Usage: %s [-h] [-C] [-D dbfile] account [state]" "$0")" | ||
386 | 387 | ||
387 | - while getopts hD: OPT | 388 | + while getopts hCD: OPT |
388 | do | 389 | do |
389 | case $OPT in | 390 | case $OPT in |
390 | D) | 391 | D) |
391 | DB="${OPTARG}";; | 392 | DB="${OPTARG}";; |
393 | + C) | ||
394 | + STDOUT=1;; | ||
392 | h) | 395 | h) |
393 | echo "${USAGE}" | 396 | echo "${USAGE}" |
394 | return 0;; | 397 | return 0;; |
@@ -410,13 +413,16 @@ function amngrgetpass() { | @@ -410,13 +413,16 @@ function amngrgetpass() { | ||
410 | fi | 413 | fi |
411 | test "${STATE}" != "1" -a "${STATE}" != "2" && STATE="1" | 414 | test "${STATE}" != "1" -a "${STATE}" != "2" && STATE="1" |
412 | 415 | ||
413 | - sqlite3 "${DB}" <<-EOD |\ | ||
414 | - awk 'NR>1{print p}{p=$0}END{ORS="";print}' | gpg -dq | xclip -i >&- | 416 | + DATA=$(sqlite3 "${DB}" " |
415 | SELECT pass FROM account | 417 | SELECT pass FROM account |
416 | JOIN account_cred ON account.id=account_cred.account_id | 418 | JOIN account_cred ON account.id=account_cred.account_id |
417 | JOIN cred ON cred.id=account_cred.cred_id | 419 | JOIN cred ON cred.id=account_cred.cred_id |
418 | - WHERE name='${ACCOUNT_NAME}' AND state=${STATE}; | ||
419 | - EOD | 420 | + WHERE name='${ACCOUNT_NAME}' AND state=${STATE};" | gpg -dq) |
421 | + if [[ $STDOUT -eq 1 ]]; then | ||
422 | + echo "$DATA" | ||
423 | + else | ||
424 | + echo "$DATA" | xclip -i >&- | ||
425 | + fi | ||
420 | } | 426 | } |
421 | 427 | ||
422 | function amngrgetoldpass() { | 428 | function amngrgetoldpass() { |
amngrgetpass
0 → 120000
1 | +accountmanager.sh |
Please
register
or
login
to post a comment