1 |
Author: ulm |
2 |
Date: 2009-04-20 06:29:02 +0000 (Mon, 20 Apr 2009) |
3 |
New Revision: 473 |
4 |
|
5 |
Modified: |
6 |
trunk/libs/editor-variable.bash.in |
7 |
Log: |
8 |
Quote consistently; use $# instead of ${#@}. Thanks vapier. |
9 |
|
10 |
Modified: trunk/libs/editor-variable.bash.in |
11 |
=================================================================== |
12 |
--- trunk/libs/editor-variable.bash.in 2009-04-20 06:18:33 UTC (rev 472) |
13 |
+++ trunk/libs/editor-variable.bash.in 2009-04-20 06:29:02 UTC (rev 473) |
14 |
@@ -36,11 +36,11 @@ |
15 |
cur=$(read_env_value) |
16 |
|
17 |
# also include the current value if it's not already in our list |
18 |
- [[ -n ${cur} ]] && ! has "${cur}" "${targets}" \ |
19 |
+ [[ -n ${cur} ]] && ! has "${cur}" ${targets} \ |
20 |
&& targets="${targets} ${cur}" |
21 |
|
22 |
for i in ${targets}; do |
23 |
- [[ -f "${ROOT}${i}" ]] && echo "${i}" |
24 |
+ [[ -f ${ROOT}${i} ]] && echo "${i}" |
25 |
done |
26 |
} |
27 |
|
28 |
@@ -51,9 +51,9 @@ |
29 |
|
30 |
# write variable to config file |
31 |
write_env_value() { |
32 |
- [[ -w "${ROOT}${EDITOR_ENVFILE%/*}" ]] \ |
33 |
+ [[ -w ${ROOT}${EDITOR_ENVFILE%/*} ]] \ |
34 |
|| die -q "You need root privileges!" |
35 |
- store_config "${ROOT}${EDITOR_ENVFILE}" "${EDITOR_VAR}" "${1}" |
36 |
+ store_config "${ROOT}${EDITOR_ENVFILE}" "${EDITOR_VAR}" "$1" |
37 |
} |
38 |
|
39 |
### show action ### |
40 |
@@ -63,7 +63,7 @@ |
41 |
} |
42 |
|
43 |
do_show() { |
44 |
- [[ ${#@} -gt 0 ]] && die -q "Too many parameters" |
45 |
+ [[ $# -gt 0 ]] && die -q "Too many parameters" |
46 |
|
47 |
local cur=$(read_env_value) |
48 |
write_list_start "${EDITOR_VAR} variable in profile:" |
49 |
@@ -77,7 +77,7 @@ |
50 |
} |
51 |
|
52 |
do_list() { |
53 |
- [[ ${#@} -gt 0 ]] && die -q "Too many parameters" |
54 |
+ [[ $# -gt 0 ]] && die -q "Too many parameters" |
55 |
|
56 |
local cur targets i |
57 |
cur=$(read_env_value) |
58 |
@@ -110,16 +110,16 @@ |
59 |
} |
60 |
|
61 |
do_set() { |
62 |
- [[ -z "${1}" ]] && die -q "You didn't tell me what to set the variable to" |
63 |
- [[ ${#@} -gt 1 ]] && die -q "Too many parameters" |
64 |
+ [[ -z $1 ]] && die -q "You didn't tell me what to set the variable to" |
65 |
+ [[ $# -gt 1 ]] && die -q "Too many parameters" |
66 |
|
67 |
- local target="${1}" targets dir ifs_save=${IFS-$' \t\n'} |
68 |
+ local target=$1 targets dir ifs_save=${IFS-$' \t\n'} |
69 |
|
70 |
# target may be specified by its name or its index |
71 |
if is_number "${target}"; then |
72 |
targets=( $(find_targets) ) |
73 |
[[ ${target} -ge 1 && ${target} -le ${#targets[@]} ]] \ |
74 |
- || die -q "Number out of range: ${1}" |
75 |
+ || die -q "Number out of range: $1" |
76 |
target=${targets[target-1]} |
77 |
fi |
78 |
|
79 |
@@ -127,7 +127,7 @@ |
80 |
if [[ -n ${target##/*} ]]; then |
81 |
IFS=: |
82 |
for dir in ${EDITOR_PATH-/bin:/usr/bin}; do |
83 |
- [[ -f "${ROOT}${dir}/${target}" ]] || continue |
84 |
+ [[ -f ${ROOT}${dir}/${target} ]] || continue |
85 |
target=${dir}/${target} |
86 |
break |
87 |
done |
88 |
@@ -135,7 +135,7 @@ |
89 |
fi |
90 |
|
91 |
# we should now have a path to an existing binary |
92 |
- [[ -z ${target##/*} && -f "${ROOT}${target}" ]] \ |
93 |
+ [[ -z ${target##/*} && -f ${ROOT}${target} ]] \ |
94 |
|| die -q "Target \"${target}\" doesn't appear to be valid!" |
95 |
|
96 |
echo "Setting ${EDITOR_VAR} to ${target} ..." |
97 |
@@ -152,11 +152,11 @@ |
98 |
} |
99 |
|
100 |
do_update() { |
101 |
- [[ ${#@} -gt 0 ]] && die -q "Too many parameters" |
102 |
+ [[ $# -gt 0 ]] && die -q "Too many parameters" |
103 |
|
104 |
local cur targets |
105 |
cur=$(read_env_value) |
106 |
- [[ -n ${cur} && -f "${ROOT}${cur}" ]] && return |
107 |
+ [[ -n ${cur} && -f ${ROOT}${cur} ]] && return |
108 |
|
109 |
targets=( $(find_targets) ) |
110 |
[[ ${#targets[@]} -gt 0 ]] \ |