]> gitweb.fluxo.info Git - keyringer.git/commitdiff
\t is a GNU extension in sed regexes; fixed / use --color only when ls supports it
authorrysiek <rysiek@example.org>
Fri, 3 Nov 2017 12:38:46 +0000 (10:38 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 3 Nov 2017 12:38:46 +0000 (10:38 -0200)
lib/keyringer/actions/recipients
lib/keyringer/functions

index 3c185160566b93fb5429219b047fe3ae575c6cef..889f73e1755654fa8c6e250c5f5622d4349883a2 100755 (executable)
@@ -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
index e3f89d9bcfb7555d0fb36d0bbf49929a4034ecc0..b1e2e085d7a782a6ce1168e28b4c16c4849a504c 100755 (executable)
@@ -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 <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"
 }