From 5c639cf8e7c819a94cac607a76bc336d40aa6ffe Mon Sep 17 00:00:00 2001 From: joshr Date: Sat, 14 Jul 2018 15:19:47 -0400 Subject: [PATCH] fixes for filenames with spaces _list_all_added_files() now sets 'filenames' var, and fixed quoting when updating hashes. --- src/commands/git_secret_changes.sh | 8 ++++---- src/commands/git_secret_hide.sh | 2 +- src/commands/git_secret_list.sh | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/commands/git_secret_changes.sh b/src/commands/git_secret_changes.sh index 61af7aeb..371a3785 100644 --- a/src/commands/git_secret_changes.sh +++ b/src/commands/git_secret_changes.sh @@ -22,16 +22,16 @@ function changes { _user_required - local filenames="$*" - if [[ -z "$filenames" ]]; then + filenames=("$@") # list of positional params. global. + if [[ ${#filenames[@]} -eq 0 ]]; then # Checking if no filenames are passed, show diff for all files. - filenames=$(_list_all_added_files) + _list_all_added_files # this sets the array variable 'filenames' fi IFS=' ' - for filename in $filenames; do + for filename in "${filenames[@]}"; do local decrypted local diff_result diff --git a/src/commands/git_secret_hide.sh b/src/commands/git_secret_hide.sh index 8f227e87..1490bcd7 100644 --- a/src/commands/git_secret_hide.sh +++ b/src/commands/git_secret_hide.sh @@ -74,7 +74,7 @@ function _optional_fsdb_update_hash { fsdb=$(_get_secrets_dir_paths_mapping) - _gawk_inplace -v key="$key" -v hash="$hash" "'$AWK_FSDB_UPDATE_HASH'" "$fsdb" + _gawk_inplace -v key="'$key'" -v hash="$hash" "'$AWK_FSDB_UPDATE_HASH'" "$fsdb" } diff --git a/src/commands/git_secret_list.sh b/src/commands/git_secret_list.sh index dccba3a5..fe757867 100644 --- a/src/commands/git_secret_list.sh +++ b/src/commands/git_secret_list.sh @@ -18,5 +18,10 @@ function list { _user_required # Command logic: - _list_all_added_files + filenames=() + _list_all_added_files # exports 'filenames' array + local filename + for filename in "${filenames[@]}"; do + echo "$filename" + done }