summaryrefslogtreecommitdiff
path: root/common.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'common.sh.in')
-rw-r--r--common.sh.in18
1 files changed, 8 insertions, 10 deletions
diff --git a/common.sh.in b/common.sh.in
index 54431fe..7b84c1f 100644
--- a/common.sh.in
+++ b/common.sh.in
@@ -69,27 +69,25 @@ version() {
# - emacs_getopt_1
# - emacs_getopt_2
emacs_getopt_init() {
- declare ifs="$IFS"
-
declare -a a_flags
- IFS=$'\n' a_flags=($(
+ readarray -t a_flags < <(
LC_ALL=C emacsclient --help |
grep ^- |
sed -e 's/\s\s.*//' -e 's/, /\n/g' |
sed -e 's/[ =].*/:/' -e 's/^-*//' |
- grep -vEx 'e|eval'))
+ grep -vEx 'e|eval'
+ )
declare -a a_flags_o a_flags_l a_flags_1 a_flags_2
- IFS=$'\n' a_flags_o=($(printf '%s\n' "${a_flags[@]}"|grep -v '^.[^:]'))
- IFS=$'\n' a_flags_l=($(printf '%s\n' "${a_flags[@]}"|grep '^.[^:]'))
- IFS=$'\n' a_flags_1=($(printf '%s\n' "${a_flags[@]}"|sed -rn -e 's/^(.)$/-\1/p' -e 's/^([^-].*[^:])$/--\1/p'))
- IFS=$'\n' a_flags_2=($(printf '%s\n' "${a_flags[@]}"|sed -rn -e 's/^(.):$/-\1/p' -e 's/^([^-].*):$/--\1/p'))
+ readarray -t a_flags_o < <(printf '%s\n' "${a_flags[@]}"|grep -v '^.[^:]')
+ readarray -t a_flags_l < <(printf '%s\n' "${a_flags[@]}"|grep '^.[^:]')
+ readarray -t a_flags_1 < <(printf '%s\n' "${a_flags[@]}"|sed -rn -e 's/^(.)$/-\1/p' -e 's/^([^-].*[^:])$/--\1/p')
+ readarray -t a_flags_2 < <(printf '%s\n' "${a_flags[@]}"|sed -rn -e 's/^(.):$/-\1/p' -e 's/^([^-].*):$/--\1/p')
+ local IFS
IFS='' emacs_getopt_o="${a_flags_o[*]}"
IFS=',' emacs_getopt_l="${a_flags_l[*]}"
IFS='|' emacs_getopt_2="^(${a_flags_2[*]})\$"
-
- IFS=$ifs
}
# Sets the global variable: