From 7f134279b78d6fa66e6ca271f95ba3633163edf8 Mon Sep 17 00:00:00 2001 From: rysiek Date: Fri, 3 Nov 2017 10:26:44 -0200 Subject: functions: handling vi better (no spurious error output --- lib/keyringer/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/keyringer/functions') diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 0d96288..e3f89d9 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 -- cgit v1.2.3 From 9363e1fa91b23297f13d51139203baf5a0090fc0 Mon Sep 17 00:00:00 2001 From: rysiek Date: Fri, 3 Nov 2017 10:38:46 -0200 Subject: \t is a GNU extension in sed regexes; fixed / use --color only when ls supports it --- lib/keyringer/actions/recipients | 4 +++- lib/keyringer/functions | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/keyringer/functions') 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/functions b/lib/keyringer/functions index e3f89d9..b1e2e08 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -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 2>/dev/null; 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 [arguments]\n\n" @@ -552,7 +557,9 @@ function keyringer_usage { if [ ! -z "$keyrings" ] && [ -z "$1" ]; then printf "\tinit [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" } -- cgit v1.2.3 From 20d8b1f626207d9731586ff11975a142befb399c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 3 Nov 2017 10:53:11 -0200 Subject: Redirect both outputs when checking 'ls' version --- lib/keyringer/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/keyringer/functions') diff --git a/lib/keyringer/functions b/lib/keyringer/functions index b1e2e08..6f9a5e3 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -538,7 +538,7 @@ function keyringer_show_actions { # Usage function keyringer_usage { # are we're using an `ls` that supports `--color`? - if ls --version 2>/dev/null; then + 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)" -- cgit v1.2.3