[PATCH] Keep existing file extension for edit command
Thomas Spurden
thomas at spurden.name
Wed Sep 5 09:21:19 CEST 2018
Excerpts from Jason A. Donenfeld's message of September 5, 2018 7:04 am:
> What about:
>
> diff --git a/src/password-store.sh b/src/password-store.sh
> index d89d455..4a05c7f 100755
> --- a/src/password-store.sh
> +++ b/src/password-store.sh
> @@ -474,7 +474,9 @@ cmd_edit() {
> set_git "$passfile"
>
> tmpdir #Defines $SECURE_TMPDIR
> - local tmp_file="$(mktemp -u "$SECURE_TMPDIR/XXXXXX")-${path//\//-}.txt"
> + local extension
> + [[ $path == *.* ]] || extension=".txt"
I think this needs to be ${path##*/} otherwise it will not add .txt to files in
directories with dots in (e.g. a.b/c).
I hadn't realised that the bash [[ could do pattern matching, neat!
> + local tmp_file="$(mktemp -u "$SECURE_TMPDIR/XXXXXX")-${path//\//-}${extension}"
>
> local action="Add"
> if [[ -f $passfile ]]; then
>
>
> Would that meet the requirements?
>
Looks good to me otherwise
More information about the Password-Store
mailing list