Commit 6400ceea8cf3e24cc26f483357675eab26fe7acf

Authored by Georg Hopp
1 parent 731b7faa

make output to stdout possible

... ... @@ -382,13 +382,16 @@ function amngrgetolduser() {
382 382
383 383 function amngrgetpass() {
384 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 389 do
389 390 case $OPT in
390 391 D)
391 392 DB="${OPTARG}";;
  393 + C)
  394 + STDOUT=1;;
392 395 h)
393 396 echo "${USAGE}"
394 397 return 0;;
... ... @@ -410,13 +413,16 @@ function amngrgetpass() {
410 413 fi
411 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 417 SELECT pass FROM account
416 418 JOIN account_cred ON account.id=account_cred.account_id
417 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 428 function amngrgetoldpass() {
... ...
  1 +accountmanager.sh
\ No newline at end of file
... ...
Please register or login to post a comment