diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/keyringer/actions/append | 1 | ||||
-rwxr-xr-x | lib/keyringer/actions/decrypt | 2 | ||||
-rwxr-xr-x | lib/keyringer/actions/find | 2 | ||||
-rwxr-xr-x | lib/keyringer/actions/pwgen | 2 | ||||
-rwxr-xr-x | lib/keyringer/actions/recipients | 4 | ||||
-rwxr-xr-x | lib/keyringer/actions/recrypt | 3 | ||||
-rwxr-xr-x | lib/keyringer/actions/sclip | 6 | ||||
-rwxr-xr-x | lib/keyringer/actions/teardown | 3 | ||||
-rwxr-xr-x | lib/keyringer/actions/tree | 7 | ||||
-rwxr-xr-x | lib/keyringer/functions | 13 |
10 files changed, 30 insertions, 13 deletions
diff --git a/lib/keyringer/actions/append b/lib/keyringer/actions/append index 905867a..ccb25fb 100755 --- a/lib/keyringer/actions/append +++ b/lib/keyringer/actions/append @@ -6,7 +6,6 @@ # Load functions LIB="`dirname $0`/../functions" source "$LIB" readwrite $* || exit 1 -exit # Get file keyringer_get_file "$2" diff --git a/lib/keyringer/actions/decrypt b/lib/keyringer/actions/decrypt index e17f0e0..7442b29 100755 --- a/lib/keyringer/actions/decrypt +++ b/lib/keyringer/actions/decrypt @@ -11,7 +11,7 @@ source "$LIB" read $* || exit 1 keyringer_get_file "$2" # Decrypt -$GPG --use-agent -d "$KEYDIR/$FILE" +cat "$KEYDIR/$FILE" | $GPG --use-agent -d - # Exit exit "$?" diff --git a/lib/keyringer/actions/find b/lib/keyringer/actions/find index 043e80d..45b4f11 100755 --- a/lib/keyringer/actions/find +++ b/lib/keyringer/actions/find @@ -15,5 +15,5 @@ shift ARGS="`echo "$*" | sed -e "s|^/*||"`" # Run find command -cd "$KEYDIR/$RELATIVE_PATH" && find | grep -i "$ARGS" | sed -e 's|^./||g' +cd "$KEYDIR/$RELATIVE_PATH" && find ./ | grep -i "$ARGS" | sed -e 's|^./||g' cd "$CWD" diff --git a/lib/keyringer/actions/pwgen b/lib/keyringer/actions/pwgen index 1ca3829..3c03681 100755 --- a/lib/keyringer/actions/pwgen +++ b/lib/keyringer/actions/pwgen @@ -32,4 +32,4 @@ elif [ ! -z "$SIZE" ] && ! echo $SIZE | egrep -q '^[0-9]+$'; then fi # Encrypt and store a randomly-generated secret -keyringer_pwgen $SIZE | keyringer_exec encrypt "$BASEDIR" "$FILE" +keyringer_pwgen $SIZE | keyringer_exec encrypt-batch "$BASEDIR" "$FILE" && echo "Secret generated and stored." diff --git a/lib/keyringer/actions/recipients b/lib/keyringer/actions/recipients index 3c18516..889f73e 100755 --- a/lib/keyringer/actions/recipients +++ b/lib/keyringer/actions/recipients @@ -38,7 +38,9 @@ elif [ "$COMMAND" == "edit" ]; then keyringer_exec git "$BASEDIR" add "$RECIPIENTS_FILE_BASE" else echo "Please specify one recipient to edit among the available:" - ls $RECIPIENTS | sed -e 's/^/\t/' + # \t is a GNU extension + # https://stackoverflow.com/questions/8400602/sed-replace-literal-tab + ls $RECIPIENTS | sed -e "`printf 's/^/\t/'`" exit 1 fi else diff --git a/lib/keyringer/actions/recrypt b/lib/keyringer/actions/recrypt index d88a749..0e2f6a0 100755 --- a/lib/keyringer/actions/recrypt +++ b/lib/keyringer/actions/recrypt @@ -9,6 +9,7 @@ source "$LIB" readwrite $* || exit 1 # Recrypt a single secret function keyringer_recrypt { + # Get file keyringer_get_file "$1" @@ -39,7 +40,7 @@ function keyringer_recrypt { if [ ! -z "$2" ]; then keyringer_recrypt $2 else - cd $KEYDIR && find | while read file; do + cd $KEYDIR && find ./ | while read file; do if [ ! -d "$KEYDIR/$file" ]; then keyringer_recrypt "$file" fi diff --git a/lib/keyringer/actions/sclip b/lib/keyringer/actions/sclip index 156762a..de9c3b5 100755 --- a/lib/keyringer/actions/sclip +++ b/lib/keyringer/actions/sclip @@ -13,12 +13,14 @@ keyringer $KEYRING xclip $* # Se window switch combo if [ -z "$XDOTOOL_NEXT_WINDOW" ]; then - XDOTOOL_NEXT_WINDOW="alt+Tab" + XDOTOOL_NEXT_WINDOW="Alt_L+Tab" fi # Move to the next window if which xdotool &> /dev/null; then - xdotool key $XDOTOOL_NEXT_WINDOW + # Use a smaller delay otherwise the window + # manager might ignore the key combo + xdotool key --delay 2 $XDOTOOL_NEXT_WINDOW fi # Sleep diff --git a/lib/keyringer/actions/teardown b/lib/keyringer/actions/teardown index 2e8725b..55de3d6 100755 --- a/lib/keyringer/actions/teardown +++ b/lib/keyringer/actions/teardown @@ -16,8 +16,9 @@ if [ -z "$CONFIRM" ] || [ "$CONFIRM" != "-y" ]; then echo "WARNING: This will irrevocably destroy $KEYDIR" echo "WARNING: the action cannot be undone!" - read -rep "Are you sure to WIPE keyring $KEYRING (type YES to confirm)? " key + read -rep "Are you sure to WIPE keyring $KEYRING (type uppercase YES to confirm)? " key if [ "$key" != "YES" ]; then + echo "CANCELLED!" exit 1 fi fi diff --git a/lib/keyringer/actions/tree b/lib/keyringer/actions/tree index 7bf173d..a877548 100755 --- a/lib/keyringer/actions/tree +++ b/lib/keyringer/actions/tree @@ -5,7 +5,7 @@ # Thanks http://www.centerkey.com/tree/ function keyringer_tree { - ls -R $* | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' + find $* | sed -e 's/[^-][^\/]*\//| /g' | sed -r -e 's/\| ([^|])/|- \1/' } # Load functions @@ -19,6 +19,11 @@ CWD="`pwd`" shift ARGS="`echo "$*" | sed -e "s|^/*||"`" +# on *BSD, find expects at least one argument with the path +if [ "$ARGS" == "" ]; then + ARGS="./" +fi + # Check implementation if which tree &> /dev/null; then TREE="tree" diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 0d96288..6f9a5e3 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -293,7 +293,7 @@ function keyringer_set_env { fi # Avoid viminfo, see https://keyringer.pw/trac/ticket/50 - if $EDITOR --help | grep -q -e "^VIM"; then + if $EDITOR --help 2>&1 | grep -q -e "^VIM"; then if ! echo $EDITOR | grep -q -- "-i NONE"; then EDITOR="$EDITOR -S $SHARE/editors/vim" fi @@ -537,7 +537,12 @@ function keyringer_show_actions { # Usage function keyringer_usage { - local keyrings="$(ls --color=never `dirname $CONFIG` | sed -e 's/config//' | xargs)" + # are we're using an `ls` that supports `--color`? + if ls --version > /dev/null 2>&1; then + local keyrings="$(ls --color=never `dirname $CONFIG` | sed -e 's/config//' | xargs)" + else + local keyrings="$(ls `dirname $CONFIG` | sed -e 's/config//' | xargs)" + fi printf "Keyringer $KEYRINGER_VERSION\n" printf "Usage: keyringer <keyring> <action> [arguments]\n\n" @@ -552,7 +557,9 @@ function keyringer_usage { if [ ! -z "$keyrings" ] && [ -z "$1" ]; then printf "\tinit <path> [remote]\n" $BASENAME fi - keyringer_show_actions | sed -e 's/^/\t/' + # \t is a GNU extension + # https://stackoverflow.com/questions/8400602/sed-replace-literal-tab + keyringer_show_actions | sed -e "`printf 's/^/\t/'`" printf "\n" } |