perf-completion.sh (552c69b36ebd966186573b9c7a286b390935cce1) perf-completion.sh (ffd1240e8f0814262ceb957dbe961f6e0aef1e7a)
1# perf bash and zsh completion
2# SPDX-License-Identifier: GPL-2.0
3
4# Taken from git.git's completion script.
5__my_reassemble_comp_words_by_ref()
6{
7 local exclude i j first
8 # Which word separators to exclude?

--- 151 unchanged lines hidden (view full) ---

160 fi
161 __perfcomp "$cmds" "$cur"
162 # List possible events for -e option
163 elif [[ $prev == @("-e"|"--event") &&
164 $prev_skip_opts == @(record|stat|top) ]]; then
165
166 local cur1=${COMP_WORDS[COMP_CWORD]}
167 local raw_evts=$($cmd list --raw-dump)
1# perf bash and zsh completion
2# SPDX-License-Identifier: GPL-2.0
3
4# Taken from git.git's completion script.
5__my_reassemble_comp_words_by_ref()
6{
7 local exclude i j first
8 # Which word separators to exclude?

--- 151 unchanged lines hidden (view full) ---

160 fi
161 __perfcomp "$cmds" "$cur"
162 # List possible events for -e option
163 elif [[ $prev == @("-e"|"--event") &&
164 $prev_skip_opts == @(record|stat|top) ]]; then
165
166 local cur1=${COMP_WORDS[COMP_CWORD]}
167 local raw_evts=$($cmd list --raw-dump)
168 local arr s tmp result
168 local arr s tmp result cpu_evts
169
169
170 # aarch64 doesn't have /sys/bus/event_source/devices/cpu/events
171 if [[ `uname -m` != aarch64 ]]; then
172 cpu_evts=$(ls /sys/bus/event_source/devices/cpu/events)
173 fi
174
170 if [[ "$cur1" == */* && ${cur1#*/} =~ ^[A-Z] ]]; then
171 OLD_IFS="$IFS"
172 IFS=" "
173 arr=($raw_evts)
174 IFS="$OLD_IFS"
175
176 for s in ${arr[@]}
177 do
178 if [[ "$s" == *cpu/* ]]; then
179 tmp=${s#*cpu/}
180 result=$result" ""cpu/"${tmp^^}
181 else
182 result=$result" "$s
183 fi
184 done
185
175 if [[ "$cur1" == */* && ${cur1#*/} =~ ^[A-Z] ]]; then
176 OLD_IFS="$IFS"
177 IFS=" "
178 arr=($raw_evts)
179 IFS="$OLD_IFS"
180
181 for s in ${arr[@]}
182 do
183 if [[ "$s" == *cpu/* ]]; then
184 tmp=${s#*cpu/}
185 result=$result" ""cpu/"${tmp^^}
186 else
187 result=$result" "$s
188 fi
189 done
190
186 evts=${result}" "$(ls /sys/bus/event_source/devices/cpu/events)
191 evts=${result}" "${cpu_evts}
187 else
192 else
188 evts=${raw_evts}" "$(ls /sys/bus/event_source/devices/cpu/events)
193 evts=${raw_evts}" "${cpu_evts}
189 fi
190
191 if [[ "$cur1" == , ]]; then
192 __perfcomp_colon "$evts" ""
193 else
194 __perfcomp_colon "$evts" "$cur1"
195 fi
196 else

--- 102 unchanged lines hidden ---
194 fi
195
196 if [[ "$cur1" == , ]]; then
197 __perfcomp_colon "$evts" ""
198 else
199 __perfcomp_colon "$evts" "$cur1"
200 fi
201 else

--- 102 unchanged lines hidden ---