Skip to content

Commit

Permalink
crlf
Browse files Browse the repository at this point in the history
  • Loading branch information
palortoff committed Feb 26, 2017
1 parent b5621ef commit 9ae0ff8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
26 changes: 13 additions & 13 deletions src/tail.bash
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

local path="$1"
local passfile="$PREFIX/$path.gpg"
check_sneaky_paths "$path"

if [[ -f $passfile ]]; then
$GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +2 || exit $?
elif [[ -z $path ]]; then
die ""
else
die "Error: $path is not in the password store."
fi
#!/bin/bash

local path="$1"
local passfile="$PREFIX/$path.gpg"
check_sneaky_paths "$path"

if [[ -f $passfile ]]; then
$GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +2 || exit $?
elif [[ -z $path ]]; then
die ""
else
die "Error: $path is not in the password store."
fi
64 changes: 32 additions & 32 deletions src/tailedit.bash
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#!/bin/bash

[[ $# -ne 1 ]] && die "Usage: $PROGRAM $COMMAND pass-name"

local path="${1%/}"
check_sneaky_paths "$path"
mkdir -p -v "$PREFIX/$(dirname "$path")"
set_gpg_recipients "$(dirname "$path")"
local passfile="$PREFIX/$path.gpg"

tmpdir #Defines $SECURE_TMPDIR
local tmp_file="$(mktemp -u "$SECURE_TMPDIR/XXXXXX")-${path//\//-}.txt"


local action="Add"
if [[ -f $passfile ]]; then
$GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +2 > "$tmp_file" || exit 1
action="Edit"
fi
${EDITOR:-vi} "$tmp_file"
[[ -f $tmp_file ]] || die "New password not saved."
$GPG -d -o - "${GPG_OPTS[@]}" "$passfile" 2>/dev/null | tail -n +2 | diff - "$tmp_file" &>/dev/null && die "Password unchanged."

local tmp_file_joined="$(mktemp -u "$SECURE_TMPDIR/XXXXXX")-${path//\//-}.txt"

$GPG -d "${GPG_OPTS[@]}" "$passfile" | head -n 1 > "$tmp_file_joined"
cat "$tmp_file" >> "$tmp_file_joined"

while ! $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" "$tmp_file_joined"; do
yesno "GPG encryption failed. Would you like to try again?"
done
git_add_file "$passfile" "$action password for $path using ${EDITOR:-vi}."
#!/bin/bash

[[ $# -ne 1 ]] && die "Usage: $PROGRAM $COMMAND pass-name"

local path="${1%/}"
check_sneaky_paths "$path"
mkdir -p -v "$PREFIX/$(dirname "$path")"
set_gpg_recipients "$(dirname "$path")"
local passfile="$PREFIX/$path.gpg"

tmpdir #Defines $SECURE_TMPDIR
local tmp_file="$(mktemp -u "$SECURE_TMPDIR/XXXXXX")-${path//\//-}.txt"


local action="Add"
if [[ -f $passfile ]]; then
$GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +2 > "$tmp_file" || exit 1
action="Edit"
fi
${EDITOR:-vi} "$tmp_file"
[[ -f $tmp_file ]] || die "New password not saved."
$GPG -d -o - "${GPG_OPTS[@]}" "$passfile" 2>/dev/null | tail -n +2 | diff - "$tmp_file" &>/dev/null && die "Password unchanged."

local tmp_file_joined="$(mktemp -u "$SECURE_TMPDIR/XXXXXX")-${path//\//-}.txt"

$GPG -d "${GPG_OPTS[@]}" "$passfile" | head -n 1 > "$tmp_file_joined"
cat "$tmp_file" >> "$tmp_file_joined"

while ! $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" "$tmp_file_joined"; do
yesno "GPG encryption failed. Would you like to try again?"
done
git_add_file "$passfile" "$action password for $path using ${EDITOR:-vi}."

0 comments on commit 9ae0ff8

Please sign in to comment.