[pass] [PATCH 2/2] Make non-POSIX flags optional

David Dahlberg david.dahlberg at fkie.fraunhofer.de
Tue Feb 9 12:59:16 CET 2016


---
 src/password-store.sh   | 22 ++++++++++++----------
 src/platform/openbsd.sh |  2 ++
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index 63be840..eaf995d 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -185,6 +185,8 @@ tmpdir() {
 }
 GETOPT="getopt"
 SHRED="shred -f -z"
+verbose="-v"
+color="--color=always"
 
 source "$(dirname "$0")/platform/$(uname | cut -d _ -f 1 | tr '[:upper:]' '[:lower:]').sh" 2>/dev/null # PLATFORM_FUNCTION_FILE
 
@@ -276,14 +278,14 @@ cmd_init() {
 
 	if [[ $# -eq 1 && -z $1 ]]; then
 		[[ ! -f "$gpg_id" ]] && die "Error: $gpg_id does not exist and so cannot be removed."
-		rm -v -f "$gpg_id" || exit 1
+		rm $verbose -f "$gpg_id" || exit 1
 		if [[ -d $GIT_DIR ]]; then
 			git rm -qr "$gpg_id"
 			git_commit "Deinitialize ${gpg_id}${id_path:+ ($id_path)}."
 		fi
 		rmdir -p "${gpg_id%/*}" 2>/dev/null
 	else
-		mkdir -v -p "$PREFIX/$id_path"
+		mkdir $verbose -p "$PREFIX/$id_path"
 		printf "%s\n" "$@" > "$gpg_id"
 		local id_print="$(printf "%s, " "$@")"
 		echo "Password store initialized for ${id_print%, }${id_path:+ ($id_path)}"
@@ -343,7 +345,7 @@ cmd_grep() {
 	[[ $# -ne 1 ]] && die "Usage: $PROGRAM $COMMAND search-string"
 	local search="$1" passfile grepresults
 	while read -r -d "" passfile; do
-		grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep --color=always "$search")"
+		grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep $color "$search")"
 		[ $? -ne 0 ] && continue
 		passfile="${passfile%.gpg}"
 		passfile="${passfile#$PREFIX/}"
@@ -374,7 +376,7 @@ cmd_insert() {
 
 	[[ $force -eq 0 && -e $passfile ]] && yesno "An entry already exists for $path. Overwrite it?"
 
-	mkdir -p -v "$PREFIX/$(dirname "$path")"
+	mkdir -p $verbose "$PREFIX/$(dirname "$path")"
 	set_gpg_recipients "$(dirname "$path")"
 
 	if [[ $multiline -eq 1 ]]; then
@@ -408,7 +410,7 @@ cmd_edit() {
 
 	local path="${1%/}"
 	check_sneaky_paths "$path"
-	mkdir -p -v "$PREFIX/$(dirname "$path")"
+	mkdir -p $verbose "$PREFIX/$(dirname "$path")"
 	set_gpg_recipients "$(dirname "$path")"
 	local passfile="$PREFIX/$path.gpg"
 
@@ -448,7 +450,7 @@ cmd_generate() {
 	local length="${2:-$GENERATED_LENGTH}"
 	check_sneaky_paths "$path"
 	[[ ! $length =~ ^[0-9]+$ ]] && die "Error: pass-length \"$length\" must be a number."
-	mkdir -p -v "$PREFIX/$(dirname "$path")"
+	mkdir -p $verbose "$PREFIX/$(dirname "$path")"
 	set_gpg_recipients "$(dirname "$path")"
 	local passfile="$PREFIX/$path.gpg"
 
@@ -499,7 +501,7 @@ cmd_delete() {
 
 	[[ $force -eq 1 ]] || yesno "Are you sure you would like to delete $path?"
 
-	rm $recursive -f -v "$passfile"
+	rm $recursive -f $verbose "$passfile"
 	if [[ -d $GIT_DIR && ! -e $passfile ]]; then
 		git rm -qr "$passfile"
 		git_commit "Remove $path from store."
@@ -531,14 +533,14 @@ cmd_copy_move() {
 	echo "$old_path"
 	[[ -e $old_path ]] || die "Error: $1 is not in the password store."
 
-	mkdir -p -v "${new_path%/*}"
+	mkdir -p $verbose "${new_path%/*}"
 	[[ -d $old_path || -d $new_path || $new_path == */ ]] || new_path="${new_path}.gpg"
 
 	local interactive="-i"
 	[[ ! -t 0 || $force -eq 1 ]] && interactive="-f"
 
 	if [[ $move -eq 1 ]]; then
-		mv $interactive -v "$old_path" "$new_path" || exit 1
+		mv $interactive $verbose "$old_path" "$new_path" || exit 1
 		[[ -e "$new_path" ]] && reencrypt_path "$new_path"
 
 		if [[ -d $GIT_DIR && ! -e $old_path ]]; then
@@ -547,7 +549,7 @@ cmd_copy_move() {
 		fi
 		rmdir -p "$old_dir" 2>/dev/null
 	else
-		cp $interactive -r -v "$old_path" "$new_path" || exit 1
+		cp $interactive -r $verbose "$old_path" "$new_path" || exit 1
 		[[ -e "$new_path" ]] && reencrypt_path "$new_path"
 		git_add_file "$new_path" "Copy ${1} to ${2}."
 	fi
diff --git a/src/platform/openbsd.sh b/src/platform/openbsd.sh
index b66b32f..589c709 100644
--- a/src/platform/openbsd.sh
+++ b/src/platform/openbsd.sh
@@ -38,3 +38,5 @@ tmpdir() {
 
 GETOPT="gnugetopt"
 SHRED="rm -P -f"
+verbose=""
+color=""
-- 
2.7.0



More information about the Password-Store mailing list