File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ _comp_xfunc_ARRAY_filter()
151
151
[[ ! $_unset ]]
152
152
}
153
153
154
+ # @version bash-4.3
154
155
_comp_uniq ()
155
156
{
156
157
local -n _comp_uniq__array=$1
@@ -163,36 +164,42 @@ _comp_uniq()
163
164
done
164
165
}
165
166
167
+ # Obtain the largest index
168
+ # @var[out] ret
169
+ # @version bash-4.3
166
170
_comp_last_index ()
167
171
{
168
- local -n _comp_last_index__array=$1 _comp_last_index__ret= $2
172
+ local -n _comp_last_index__array=$1
169
173
local -a _comp_last_index__indices=(" ${! _comp_last_index__array[@]} " )
170
- _comp_last_index__ret =${_comp_last_index__indices[*]: -1}
174
+ ret =${_comp_last_index__indices[*]: -1}
171
175
}
172
176
177
+ # @version bash-4.3
173
178
_comp_compact ()
174
179
{
175
180
local -n _comp_compact__array=$1
176
181
_comp_compact__array=(" ${_comp_compact__array[@]} " )
177
182
}
178
183
184
+ # Find the index of a matching element
185
+ # @var[out] ret
186
+ # @version bash-4.3
179
187
_comp_index_of ()
180
188
{
181
189
# TODO getopts -> -r gets rightmost (last) index
182
190
# TODO getopts: -R uses regex instead of glob
183
191
local -n _comp_index_of__array=$1
184
192
local _comp_compact__pattern=$2
185
- local -n _comp_index_of__ret=$3
186
193
187
194
local -i _comp_index_of__i
188
195
for _comp_index_of__i in " ${! _comp_index_of__array[@]} " ; do
189
196
# shellcheck disable=SC2053
190
197
if [[ ${_comp_index_of__array[_comp_index_of__i]} == $_comp_compact__pattern ]]; then
191
- _comp_index_of__ret =$_comp_index_of__i
198
+ ret =$_comp_index_of__i
192
199
return 0
193
200
fi
194
201
done
195
202
196
- _comp_index_of__ret =-1
203
+ ret =-1
197
204
return 1
198
205
}
You can’t perform that action at this time.
0 commit comments