[PATCH] Add --pass-only option to show subcommand

Matthias De Bie mattydebie at gmail.com
Wed Jan 30 13:11:40 CET 2019


diff --git a/src/password-store.sh b/src/password-store.sh
index d89d455..0c45365 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -347,24 +347,25 @@ cmd_init() {
 }
 
 cmd_show() {
- local opts selected_line clip=0 qrcode=0
- opts="$($GETOPT -o q::c:: -l qrcode::,clip:: -n "$PROGRAM" -- "$@")"
+ local opts selected_line clip=0 qrcode=0 passonly=0
+ opts="$($GETOPT -o q::c:: -l qrcode::,clip::,pass-only -n "$PROGRAM" -- "$@")"
  local err=$?
  eval set -- "$opts"
  while true; do case $1 in
   -q|--qrcode) qrcode=1; selected_line="${2:-1}"; shift 2 ;;
   -c|--clip) clip=1; selected_line="${2:-1}"; shift 2 ;;
+  --pass-only) passonly=1; selected_line="1"; shift ;;
   --) shift; break ;;
  esac done
 
- [[ $err -ne 0 || ( $qrcode -eq 1 && $clip -eq 1 ) ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line-number],-c[line-number]] [--qrcode[=line-number],-q[line-number]] [pass-name]"
+ [[ $err -ne 0 || ( $qrcode -eq 1 && $clip -eq 1 ) ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line-number],-c[line-number]] [--qrcode[=line-number],-q[line-number]] [--pass-only] [pass-name]"
 
  local pass
  local path="$1"
  local passfile="$PREFIX/$path.gpg"
  check_sneaky_paths "$path"
  if [[ -f $passfile ]]; then
-  if [[ $clip -eq 0 && $qrcode -eq 0 ]]; then
+  if [[ $clip -eq 0 && $qrcode -eq 0 && $passonly -eq 0 ]]; then
    pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | $BASE64)" || exit $?
    echo "$pass" | $BASE64 -d
   else
@@ -375,6 +376,8 @@ cmd_show() {
     clip "$pass" "$path"
    elif [[ $qrcode -eq 1 ]]; then
     qrcode "$pass" "$path"
+   elif [[ $passonly -eq 1 ]]; then
+    echo "$pass" 
    fi
   fi
  elif [[ -d $PREFIX/$path ]]; then


More information about the Password-Store mailing list