From 50b23c973935eeb63e08f122a56e1cbcec29f404 Mon Sep 17 00:00:00 2001 From: Josh Rabinowitz Date: Sat, 14 Apr 2018 10:05:27 -0400 Subject: [PATCH] fix --- src/commands/git_secret_cat.sh | 44 ++++++++++++++++++++++++++++++++++ tests/test_cat.bats | 1 + 2 files changed, 45 insertions(+) create mode 100644 src/commands/git_secret_cat.sh diff --git a/src/commands/git_secret_cat.sh b/src/commands/git_secret_cat.sh new file mode 100644 index 00000000..a1b86180 --- /dev/null +++ b/src/commands/git_secret_cat.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + + +function cat { + local homedir='' + local passphrase='' + + OPTIND=1 + + while getopts 'hd:p:' opt; do + case "$opt" in + h) _show_manual_for 'cat';; + + p) passphrase=$OPTARG;; + + d) homedir=$OPTARG;; + + *) _invalid_option_for 'cat';; + esac + done + + shift $((OPTIND-1)) + [ "$1" = '--' ] && shift + + _user_required + + # Command logic: + + for line in "$@" + do + local filename + local path + + filename=$(_get_record_filename "$line") + path=$(_append_root_path "$filename") + + # The parameters are: filename, write-to-file, force, homedir, passphrase + _decrypt "$path" "0" "0" "$homedir" "$passphrase" + + #if [[ "$?" ne "0" ]]; then + # _abort( "error decrypting $(filename): $?" ) + #fi + done +} diff --git a/tests/test_cat.bats b/tests/test_cat.bats index d08fca52..6b2578de 100644 --- a/tests/test_cat.bats +++ b/tests/test_cat.bats @@ -40,6 +40,7 @@ function teardown { # $output is the output from 'git secret cat' above [ "$FILE_CONTENTS" == "$output" ] + touch "$FILE_TO_HIDE)" rm "${FILE_TO_HIDE}2" }