linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] Minor perf completion improvements
@ 2013-07-04 12:41 Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 1/7] perf completion: don't dictate perf install location Ramkumar Ramachandra
                   ` (8 more replies)
  0 siblings, 9 replies; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML

Hi,

So I just started using perf, and noticed the accompanying completion
script. Having dabbled with git.git's completion script a bit, I
thought I should contribute what I learnt from it.

[6/7] is the meat of the series, and the preceding patches work
towards the same goal: to strip dependency on the bash-completion
package.

Thanks.

Ramkumar Ramachandra (7):
  perf completion: don't dictate perf install location
  perf completion: update __ltrim_colon_completions
  perf completion: strip dependency on _filedir
  perf completion: modernize style
  perf completion: strip function_exists ()
  perf completion: strip dependency on bash-completion
  perf completion: use more comp words

 tools/perf/bash_completion | 110 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 87 insertions(+), 23 deletions(-)

-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/7] perf completion: don't dictate perf install location
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
@ 2013-07-04 12:41 ` Ramkumar Ramachandra
  2013-10-15  5:22   ` [tip:perf/core] perf completion: Don' t " tip-bot for Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 2/7] perf completion: update __ltrim_colon_completions Ramkumar Ramachandra
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML; +Cc: Frederic Weisbecker

The statement

  have perf

limits the locations in which to look for the perf program.  Moreover,
it depends on the bash-completion package to be installed.  Replace it
with a call to `type perf`.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/bash_completion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 56e6a12..50540cf 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -19,7 +19,7 @@ __ltrim_colon_completions()
 	fi
 }
 
-have perf &&
+type perf &>/dev/null &&
 _perf()
 {
 	local cur prev cmd
-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/7] perf completion: update __ltrim_colon_completions
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 1/7] perf completion: don't dictate perf install location Ramkumar Ramachandra
@ 2013-07-04 12:41 ` Ramkumar Ramachandra
  2013-10-15  5:22   ` [tip:perf/core] perf completion: Update __ltrim_colon_completions tip-bot for Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 3/7] perf completion: strip dependency on _filedir Ramkumar Ramachandra
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML; +Cc: Frederic Weisbecker

The function is taken from the bash-completion package; update it to use
the latest version where colon_word doesn't miss quoting.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/bash_completion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 50540cf..b0cdd12 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -11,7 +11,7 @@ __ltrim_colon_completions()
 {
 	if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
 		# Remove colon-word prefix from COMPREPLY items
-		local colon_word=${1%${1##*:}}
+		local colon_word=${1%"${1##*:}"}
 		local i=${#COMPREPLY[*]}
 		while [[ $((--i)) -ge 0 ]]; do
 			COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/7] perf completion: strip dependency on _filedir
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 1/7] perf completion: don't dictate perf install location Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 2/7] perf completion: update __ltrim_colon_completions Ramkumar Ramachandra
@ 2013-07-04 12:41 ` Ramkumar Ramachandra
  2013-10-15  5:23   ` [tip:perf/core] perf completion: Strip " tip-bot for Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 4/7] perf completion: modernize style Ramkumar Ramachandra
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML; +Cc: Frederic Weisbecker

_filedir is defined in the bash-completion package, but there is no need
to depend on it.  Instead, call complete with multiple -o arguments
before the -F argument like in git.git's completion script.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/bash_completion | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index b0cdd12..d2598be 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -54,9 +54,8 @@ _perf()
 		subcmd=${COMP_WORDS[1]}
 		opts=$($cmd $subcmd --list-opts)
 		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
-	# Fall down to list regular files
-	else
-		_filedir
 	fi
 } &&
-complete -F _perf perf
+
+complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \
+	|| complete -o default -o nospace -F _perf perf
-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 4/7] perf completion: modernize style
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
                   ` (2 preceding siblings ...)
  2013-07-04 12:41 ` [PATCH 3/7] perf completion: strip dependency on _filedir Ramkumar Ramachandra
@ 2013-07-04 12:41 ` Ramkumar Ramachandra
  2013-07-16 17:19   ` Arnaldo Carvalho de Melo
  2013-07-04 12:41 ` [PATCH 5/7] perf completion: strip function_exists () Ramkumar Ramachandra
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/bash_completion | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index d2598be..8c04f5d 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -7,7 +7,7 @@ function_exists()
 }
 
 function_exists __ltrim_colon_completions ||
-__ltrim_colon_completions()
+__ltrim_colon_completions ()
 {
 	if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
 		# Remove colon-word prefix from COMPREPLY items
@@ -20,7 +20,7 @@ __ltrim_colon_completions()
 }
 
 type perf &>/dev/null &&
-_perf()
+_perf ()
 {
 	local cur prev cmd
 
-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 5/7] perf completion: strip function_exists ()
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
                   ` (3 preceding siblings ...)
  2013-07-04 12:41 ` [PATCH 4/7] perf completion: modernize style Ramkumar Ramachandra
@ 2013-07-04 12:41 ` Ramkumar Ramachandra
  2013-10-15  5:23   ` [tip:perf/core] perf completion: Strip " tip-bot for Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 6/7] perf completion: strip dependency on bash-completion Ramkumar Ramachandra
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML; +Cc: Frederic Weisbecker

Use "type" to check existence consistently.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/bash_completion | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 8c04f5d..852d444 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -1,12 +1,6 @@
 # perf completion
 
-function_exists()
-{
-	declare -F $1 > /dev/null
-	return $?
-}
-
-function_exists __ltrim_colon_completions ||
+type __ltrim_colon_completions &>/dev/null ||
 __ltrim_colon_completions ()
 {
 	if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 6/7] perf completion: strip dependency on bash-completion
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
                   ` (4 preceding siblings ...)
  2013-07-04 12:41 ` [PATCH 5/7] perf completion: strip function_exists () Ramkumar Ramachandra
@ 2013-07-04 12:41 ` Ramkumar Ramachandra
  2013-10-15  5:23   ` [tip:perf/core] perf completion: Strip " tip-bot for Ramkumar Ramachandra
  2013-07-04 12:41 ` [PATCH 7/7] perf completion: use more comp words Ramkumar Ramachandra
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML; +Cc: Namhyung Kim, Frederic Weisbecker

The bash-completion package defines the _get_comp_words_by_ref
function.  There is no need to depend on it, as we can reimplement it
like git.git has.

Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/bash_completion | 83 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 77 insertions(+), 6 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 852d444..765fb2f 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -1,5 +1,81 @@
 # perf completion
 
+# Taken from git.git's completion script.
+__my_reassemble_comp_words_by_ref ()
+{
+	local exclude i j first
+	# Which word separators to exclude?
+	exclude="${1//[^$COMP_WORDBREAKS]}"
+	cword_=$COMP_CWORD
+	if [ -z "$exclude" ]; then
+		words_=("${COMP_WORDS[@]}")
+		return
+	fi
+	# List of word completion separators has shrunk;
+	# re-assemble words to complete.
+	for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
+		# Append each nonempty word consisting of just
+		# word separator characters to the current word.
+		first=t
+		while
+			[ $i -gt 0 ] &&
+			[ -n "${COMP_WORDS[$i]}" ] &&
+			# word consists of excluded word separators
+			[ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
+		do
+			# Attach to the previous token,
+			# unless the previous token is the command name.
+			if [ $j -ge 2 ] && [ -n "$first" ]; then
+				((j--))
+			fi
+			first=
+			words_[$j]=${words_[j]}${COMP_WORDS[i]}
+			if [ $i = $COMP_CWORD ]; then
+				cword_=$j
+			fi
+			if (($i < ${#COMP_WORDS[@]} - 1)); then
+				((i++))
+			else
+				# Done.
+				return
+			fi
+		done
+		words_[$j]=${words_[j]}${COMP_WORDS[i]}
+		if [ $i = $COMP_CWORD ]; then
+			cword_=$j
+		fi
+	done
+}
+
+type _get_comp_words_by_ref &>/dev/null ||
+_get_comp_words_by_ref ()
+{
+	local exclude cur_ words_ cword_
+	if [ "$1" = "-n" ]; then
+		exclude=$2
+		shift 2
+	fi
+	__my_reassemble_comp_words_by_ref "$exclude"
+	cur_=${words_[cword_]}
+	while [ $# -gt 0 ]; do
+		case "$1" in
+		cur)
+			cur=$cur_
+			;;
+		prev)
+			prev=${words_[$cword_-1]}
+			;;
+		words)
+			words=("${words_[@]}")
+			;;
+		cword)
+			cword=$cword_
+			;;
+		esac
+		shift
+	done
+}
+
 type __ltrim_colon_completions &>/dev/null ||
 __ltrim_colon_completions ()
 {
@@ -19,12 +95,7 @@ _perf ()
 	local cur prev cmd
 
 	COMPREPLY=()
-	if function_exists _get_comp_words_by_ref; then
-		_get_comp_words_by_ref -n : cur prev
-	else
-		cur=$(_get_cword :)
-		prev=${COMP_WORDS[COMP_CWORD-1]}
-	fi
+	_get_comp_words_by_ref -n : cur prev
 
 	cmd=${COMP_WORDS[0]}
 
-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 7/7] perf completion: use more comp words
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
                   ` (5 preceding siblings ...)
  2013-07-04 12:41 ` [PATCH 6/7] perf completion: strip dependency on bash-completion Ramkumar Ramachandra
@ 2013-07-04 12:41 ` Ramkumar Ramachandra
  2013-10-15  5:23   ` [tip:perf/core] perf completion: Use " tip-bot for Ramkumar Ramachandra
  2013-07-05  2:46 ` [PATCH 0/7] Minor perf completion improvements Namhyung Kim
  2013-07-15  7:51 ` Ramkumar Ramachandra
  8 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-04 12:41 UTC (permalink / raw)
  To: LKML; +Cc: Frederic Weisbecker

The completion words $words and $cword are available, so we might as
well use them instead of directly accessing COMP_WORDS.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/bash_completion | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 765fb2f..9bb5f4d 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -92,15 +92,15 @@ __ltrim_colon_completions ()
 type perf &>/dev/null &&
 _perf ()
 {
-	local cur prev cmd
+	local cur words cword prev cmd
 
 	COMPREPLY=()
-	_get_comp_words_by_ref -n : cur prev
+	_get_comp_words_by_ref -n =: cur words cword prev
 
-	cmd=${COMP_WORDS[0]}
+	cmd=${words[0]}
 
 	# List perf subcommands or long options
-	if [ $COMP_CWORD -eq 1 ]; then
+	if [ $cword -eq 1 ]; then
 		if [[ $cur == --* ]]; then
 			COMPREPLY=( $( compgen -W '--help --version \
 			--exec-path --html-path --paginate --no-pager \
@@ -110,13 +110,13 @@ _perf ()
 			COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
 		fi
 	# List possible events for -e option
-	elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then
+	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
 		COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) )
 		__ltrim_colon_completions $cur
 	# List long option names
 	elif [[ $cur == --* ]];  then
-		subcmd=${COMP_WORDS[1]}
+		subcmd=${words[1]}
 		opts=$($cmd $subcmd --list-opts)
 		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
 	fi
-- 
1.8.3.1.643.gebeea52.dirty


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/7] Minor perf completion improvements
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
                   ` (6 preceding siblings ...)
  2013-07-04 12:41 ` [PATCH 7/7] perf completion: use more comp words Ramkumar Ramachandra
@ 2013-07-05  2:46 ` Namhyung Kim
  2013-07-05 10:03   ` Ramkumar Ramachandra
  2013-07-15  7:51 ` Ramkumar Ramachandra
  8 siblings, 1 reply; 22+ messages in thread
From: Namhyung Kim @ 2013-07-05  2:46 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: LKML

On Thu,  4 Jul 2013 18:11:24 +0530, Ramkumar Ramachandra wrote:
> Hi,
>
> So I just started using perf, and noticed the accompanying completion
> script. Having dabbled with git.git's completion script a bit, I
> thought I should contribute what I learnt from it.
>
> [6/7] is the meat of the series, and the preceding patches work
> towards the same goal: to strip dependency on the bash-completion
> package.

So the whole point of this patchset is removing dependency, and no
functional change, right?

It'd be great if the completion script supports multiple events
separated by comma esp. in a group syntax (i.e. surrounded be a pair of
curly braces: -e '{cache-references,cache-misses}').  Could you take a
look at that if possible?

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/7] Minor perf completion improvements
  2013-07-05  2:46 ` [PATCH 0/7] Minor perf completion improvements Namhyung Kim
@ 2013-07-05 10:03   ` Ramkumar Ramachandra
  0 siblings, 0 replies; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-05 10:03 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: LKML

Namhyung Kim wrote:
> So the whole point of this patchset is removing dependency, and no
> functional change, right?

Yep, and to lay the groundwork for extensibility: I would like to add
ZSH support in a future patchset, for instance.

> It'd be great if the completion script supports multiple events
> separated by comma esp. in a group syntax (i.e. surrounded be a pair of
> curly braces: -e '{cache-references,cache-misses}').  Could you take a
> look at that if possible?

Sure, thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 0/7] Minor perf completion improvements
  2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
                   ` (7 preceding siblings ...)
  2013-07-05  2:46 ` [PATCH 0/7] Minor perf completion improvements Namhyung Kim
@ 2013-07-15  7:51 ` Ramkumar Ramachandra
  8 siblings, 0 replies; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-15  7:51 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo

Ping?

Does this series look alright?

On Thu, Jul 4, 2013 at 6:11 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> Hi,
>
> So I just started using perf, and noticed the accompanying completion
> script. Having dabbled with git.git's completion script a bit, I
> thought I should contribute what I learnt from it.
>
> [6/7] is the meat of the series, and the preceding patches work
> towards the same goal: to strip dependency on the bash-completion
> package.
>
> Thanks.
>
> Ramkumar Ramachandra (7):
>   perf completion: don't dictate perf install location
>   perf completion: update __ltrim_colon_completions
>   perf completion: strip dependency on _filedir
>   perf completion: modernize style
>   perf completion: strip function_exists ()
>   perf completion: strip dependency on bash-completion
>   perf completion: use more comp words
>
>  tools/perf/bash_completion | 110 +++++++++++++++++++++++++++++++++++----------
>  1 file changed, 87 insertions(+), 23 deletions(-)
>
> --
> 1.8.3.1.643.gebeea52.dirty
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/7] perf completion: modernize style
  2013-07-04 12:41 ` [PATCH 4/7] perf completion: modernize style Ramkumar Ramachandra
@ 2013-07-16 17:19   ` Arnaldo Carvalho de Melo
  2013-07-16 17:22     ` Ramkumar Ramachandra
  0 siblings, 1 reply; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-07-16 17:19 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: LKML

Em Thu, Jul 04, 2013 at 06:11:28PM +0530, Ramkumar Ramachandra escreveu:
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  tools/perf/bash_completion | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
> index d2598be..8c04f5d 100644
> --- a/tools/perf/bash_completion
> +++ b/tools/perf/bash_completion
> @@ -7,7 +7,7 @@ function_exists()
>  }
>  
>  function_exists __ltrim_colon_completions ||
> -__ltrim_colon_completions()
> +__ltrim_colon_completions ()

Huh? Why would this be more "modern", if both are equivalent, I think
applying the same rules as we have for C code applies here.

- Arnaldo

>  {
>  	if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
>  		# Remove colon-word prefix from COMPREPLY items
> @@ -20,7 +20,7 @@ __ltrim_colon_completions()
>  }
>  
>  type perf &>/dev/null &&
> -_perf()
> +_perf ()
>  {
>  	local cur prev cmd
>  
> -- 
> 1.8.3.1.643.gebeea52.dirty
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/7] perf completion: modernize style
  2013-07-16 17:19   ` Arnaldo Carvalho de Melo
@ 2013-07-16 17:22     ` Ramkumar Ramachandra
  2013-08-07 20:26       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-16 17:22 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: LKML

Arnaldo Carvalho de Melo wrote:
> Huh? Why would this be more "modern", if both are equivalent, I think
> applying the same rules as we have for C code applies here.

It's the prevalent style in git.git, and I figured that it was picked
up from linux.git but didn't check.  Drop this part otherwise.

Thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/7] perf completion: modernize style
  2013-07-16 17:22     ` Ramkumar Ramachandra
@ 2013-08-07 20:26       ` Arnaldo Carvalho de Melo
  2013-08-08  4:19         ` Ramkumar Ramachandra
  2013-09-18 23:31         ` Ramkumar Ramachandra
  0 siblings, 2 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-08-07 20:26 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: LKML

Em Tue, Jul 16, 2013 at 10:52:55PM +0530, Ramkumar Ramachandra escreveu:
> Arnaldo Carvalho de Melo wrote:
> > Huh? Why would this be more "modern", if both are equivalent, I think
> > applying the same rules as we have for C code applies here.
> 
> It's the prevalent style in git.git, and I figured that it was picked
> up from linux.git but didn't check.  Drop this part otherwise.

Can you check how is this in the current perf/core branch so that we can
move forward while I process some other patches?

- Arnaldo

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/7] perf completion: modernize style
  2013-08-07 20:26       ` Arnaldo Carvalho de Melo
@ 2013-08-08  4:19         ` Ramkumar Ramachandra
  2013-09-18 23:31         ` Ramkumar Ramachandra
  1 sibling, 0 replies; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-08-08  4:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: LKML

Arnaldo Carvalho de Melo wrote:
> Can you check how is this in the current perf/core branch so that we can
> move forward while I process some other patches?

This series (except this part) was merged into perf/completion of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux 3 weeks ago,
so I'm not sure what perf/core has to do with it.

To answer your question about prevalent style:

  $ git grep "[^ ]()" -- \*.sh

returns many more results than

  $ git grep " ()" -- \*.sh

This is different from what you will see in git.git.

Anyway, consistent style is important in shell scripts mainly because
we don't have semantic parsers and have to rely on it being grep'able
to find something. So, yeah: perf/completion is good as it is.

Thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/7] perf completion: modernize style
  2013-08-07 20:26       ` Arnaldo Carvalho de Melo
  2013-08-08  4:19         ` Ramkumar Ramachandra
@ 2013-09-18 23:31         ` Ramkumar Ramachandra
  1 sibling, 0 replies; 22+ messages in thread
From: Ramkumar Ramachandra @ 2013-09-18 23:31 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: LKML

Hi Arnaldo,

Arnaldo Carvalho de Melo wrote:
> Can you check how is this in the current perf/core branch so that we can
> move forward while I process some other patches?

perf/completion is now 3 months old, and my more recent patches have
already been merged into Linus' tree. Why is perf/completion being
held up? It should be trivial enough to merge, no?

Thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [tip:perf/core] perf completion: Don' t dictate perf install location
  2013-07-04 12:41 ` [PATCH 1/7] perf completion: don't dictate perf install location Ramkumar Ramachandra
@ 2013-10-15  5:22   ` tip-bot for Ramkumar Ramachandra
  0 siblings, 0 replies; 22+ messages in thread
From: tip-bot for Ramkumar Ramachandra @ 2013-10-15  5:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, fweisbec, artagnon, tglx

Commit-ID:  1ba6e01782fd2a94481e18b91b363636f8171565
Gitweb:     http://git.kernel.org/tip/1ba6e01782fd2a94481e18b91b363636f8171565
Author:     Ramkumar Ramachandra <artagnon@gmail.com>
AuthorDate: Thu, 4 Jul 2013 18:11:25 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Oct 2013 11:11:40 -0300

perf completion: Don't dictate perf install location

The statement

  have perf

limits the locations in which to look for the perf program.  Moreover,
it depends on the bash-completion package to be installed.  Replace it
with a call to `type perf`.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1372941691-14684-2-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bash_completion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 56e6a12..50540cf 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -19,7 +19,7 @@ __ltrim_colon_completions()
 	fi
 }
 
-have perf &&
+type perf &>/dev/null &&
 _perf()
 {
 	local cur prev cmd

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [tip:perf/core] perf completion: Update __ltrim_colon_completions
  2013-07-04 12:41 ` [PATCH 2/7] perf completion: update __ltrim_colon_completions Ramkumar Ramachandra
@ 2013-10-15  5:22   ` tip-bot for Ramkumar Ramachandra
  0 siblings, 0 replies; 22+ messages in thread
From: tip-bot for Ramkumar Ramachandra @ 2013-10-15  5:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, fweisbec, artagnon, tglx

Commit-ID:  30079d1d5ebcb8d706c6e05cacebb7facc60cd95
Gitweb:     http://git.kernel.org/tip/30079d1d5ebcb8d706c6e05cacebb7facc60cd95
Author:     Ramkumar Ramachandra <artagnon@gmail.com>
AuthorDate: Thu, 4 Jul 2013 18:11:26 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Oct 2013 11:11:48 -0300

perf completion: Update __ltrim_colon_completions

The function is taken from the bash-completion package; update it to use
the latest version where colon_word doesn't miss quoting.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1372941691-14684-3-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bash_completion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 50540cf..b0cdd12 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -11,7 +11,7 @@ __ltrim_colon_completions()
 {
 	if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
 		# Remove colon-word prefix from COMPREPLY items
-		local colon_word=${1%${1##*:}}
+		local colon_word=${1%"${1##*:}"}
 		local i=${#COMPREPLY[*]}
 		while [[ $((--i)) -ge 0 ]]; do
 			COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [tip:perf/core] perf completion: Strip dependency on _filedir
  2013-07-04 12:41 ` [PATCH 3/7] perf completion: strip dependency on _filedir Ramkumar Ramachandra
@ 2013-10-15  5:23   ` tip-bot for Ramkumar Ramachandra
  0 siblings, 0 replies; 22+ messages in thread
From: tip-bot for Ramkumar Ramachandra @ 2013-10-15  5:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, fweisbec, artagnon, tglx

Commit-ID:  7b6c48e16e5d312b0ebae78acfb3ff4f9c8c083c
Gitweb:     http://git.kernel.org/tip/7b6c48e16e5d312b0ebae78acfb3ff4f9c8c083c
Author:     Ramkumar Ramachandra <artagnon@gmail.com>
AuthorDate: Thu, 4 Jul 2013 18:11:27 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Oct 2013 11:11:55 -0300

perf completion: Strip dependency on _filedir

_filedir is defined in the bash-completion package, but there is no need
to depend on it.  Instead, call complete with multiple -o arguments
before the -F argument like in git.git's completion script.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1372941691-14684-4-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bash_completion | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index b0cdd12..d2598be 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -54,9 +54,8 @@ _perf()
 		subcmd=${COMP_WORDS[1]}
 		opts=$($cmd $subcmd --list-opts)
 		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
-	# Fall down to list regular files
-	else
-		_filedir
 	fi
 } &&
-complete -F _perf perf
+
+complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \
+	|| complete -o default -o nospace -F _perf perf

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [tip:perf/core] perf completion: Strip function_exists ()
  2013-07-04 12:41 ` [PATCH 5/7] perf completion: strip function_exists () Ramkumar Ramachandra
@ 2013-10-15  5:23   ` tip-bot for Ramkumar Ramachandra
  0 siblings, 0 replies; 22+ messages in thread
From: tip-bot for Ramkumar Ramachandra @ 2013-10-15  5:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, fweisbec, artagnon, tglx

Commit-ID:  4685a6cfaeac6d2fe8ed10a9aa0cbff5026529cb
Gitweb:     http://git.kernel.org/tip/4685a6cfaeac6d2fe8ed10a9aa0cbff5026529cb
Author:     Ramkumar Ramachandra <artagnon@gmail.com>
AuthorDate: Thu, 4 Jul 2013 18:11:29 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Oct 2013 11:12:06 -0300

perf completion: Strip function_exists ()

Use "type" to check existence consistently.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1372941691-14684-6-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bash_completion | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index d2598be..35fdda1 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -1,12 +1,6 @@
 # perf completion
 
-function_exists()
-{
-	declare -F $1 > /dev/null
-	return $?
-}
-
-function_exists __ltrim_colon_completions ||
+type __ltrim_colon_completions &>/dev/null ||
 __ltrim_colon_completions()
 {
 	if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [tip:perf/core] perf completion: Strip dependency on bash-completion
  2013-07-04 12:41 ` [PATCH 6/7] perf completion: strip dependency on bash-completion Ramkumar Ramachandra
@ 2013-10-15  5:23   ` tip-bot for Ramkumar Ramachandra
  0 siblings, 0 replies; 22+ messages in thread
From: tip-bot for Ramkumar Ramachandra @ 2013-10-15  5:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, namhyung.kim, fweisbec, tglx, artagnon

Commit-ID:  c3fb6717e90049b93d0f5f5714a4d878799d89c2
Gitweb:     http://git.kernel.org/tip/c3fb6717e90049b93d0f5f5714a4d878799d89c2
Author:     Ramkumar Ramachandra <artagnon@gmail.com>
AuthorDate: Thu, 4 Jul 2013 18:11:30 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Oct 2013 11:12:24 -0300

perf completion: Strip dependency on bash-completion

The bash-completion package defines the _get_comp_words_by_ref function.
There is no need to depend on it, as we can reimplement it like git.git
has.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Link: http://lkml.kernel.org/r/1372941691-14684-7-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bash_completion | 83 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 77 insertions(+), 6 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 35fdda1..ee9c6d8 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -1,5 +1,81 @@
 # perf completion
 
+# Taken from git.git's completion script.
+__my_reassemble_comp_words_by_ref()
+{
+	local exclude i j first
+	# Which word separators to exclude?
+	exclude="${1//[^$COMP_WORDBREAKS]}"
+	cword_=$COMP_CWORD
+	if [ -z "$exclude" ]; then
+		words_=("${COMP_WORDS[@]}")
+		return
+	fi
+	# List of word completion separators has shrunk;
+	# re-assemble words to complete.
+	for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
+		# Append each nonempty word consisting of just
+		# word separator characters to the current word.
+		first=t
+		while
+			[ $i -gt 0 ] &&
+			[ -n "${COMP_WORDS[$i]}" ] &&
+			# word consists of excluded word separators
+			[ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
+		do
+			# Attach to the previous token,
+			# unless the previous token is the command name.
+			if [ $j -ge 2 ] && [ -n "$first" ]; then
+				((j--))
+			fi
+			first=
+			words_[$j]=${words_[j]}${COMP_WORDS[i]}
+			if [ $i = $COMP_CWORD ]; then
+				cword_=$j
+			fi
+			if (($i < ${#COMP_WORDS[@]} - 1)); then
+				((i++))
+			else
+				# Done.
+				return
+			fi
+		done
+		words_[$j]=${words_[j]}${COMP_WORDS[i]}
+		if [ $i = $COMP_CWORD ]; then
+			cword_=$j
+		fi
+	done
+}
+
+type _get_comp_words_by_ref &>/dev/null ||
+_get_comp_words_by_ref()
+{
+	local exclude cur_ words_ cword_
+	if [ "$1" = "-n" ]; then
+		exclude=$2
+		shift 2
+	fi
+	__my_reassemble_comp_words_by_ref "$exclude"
+	cur_=${words_[cword_]}
+	while [ $# -gt 0 ]; do
+		case "$1" in
+		cur)
+			cur=$cur_
+			;;
+		prev)
+			prev=${words_[$cword_-1]}
+			;;
+		words)
+			words=("${words_[@]}")
+			;;
+		cword)
+			cword=$cword_
+			;;
+		esac
+		shift
+	done
+}
+
 type __ltrim_colon_completions &>/dev/null ||
 __ltrim_colon_completions()
 {
@@ -19,12 +95,7 @@ _perf()
 	local cur prev cmd
 
 	COMPREPLY=()
-	if function_exists _get_comp_words_by_ref; then
-		_get_comp_words_by_ref -n : cur prev
-	else
-		cur=$(_get_cword :)
-		prev=${COMP_WORDS[COMP_CWORD-1]}
-	fi
+	_get_comp_words_by_ref -n : cur prev
 
 	cmd=${COMP_WORDS[0]}
 

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [tip:perf/core] perf completion: Use more comp words
  2013-07-04 12:41 ` [PATCH 7/7] perf completion: use more comp words Ramkumar Ramachandra
@ 2013-10-15  5:23   ` tip-bot for Ramkumar Ramachandra
  0 siblings, 0 replies; 22+ messages in thread
From: tip-bot for Ramkumar Ramachandra @ 2013-10-15  5:23 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, fweisbec, artagnon, tglx

Commit-ID:  6e0dc374a2c912a8a967ea8a4f9696dd4b0a6d3e
Gitweb:     http://git.kernel.org/tip/6e0dc374a2c912a8a967ea8a4f9696dd4b0a6d3e
Author:     Ramkumar Ramachandra <artagnon@gmail.com>
AuthorDate: Thu, 4 Jul 2013 18:11:31 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Oct 2013 11:12:31 -0300

perf completion: Use more comp words

The completion words $words and $cword are available, so we might as
well use them instead of directly accessing COMP_WORDS.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1372941691-14684-8-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bash_completion | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index ee9c6d8..62e157db 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -92,15 +92,15 @@ __ltrim_colon_completions()
 type perf &>/dev/null &&
 _perf()
 {
-	local cur prev cmd
+	local cur words cword prev cmd
 
 	COMPREPLY=()
-	_get_comp_words_by_ref -n : cur prev
+	_get_comp_words_by_ref -n =: cur words cword prev
 
-	cmd=${COMP_WORDS[0]}
+	cmd=${words[0]}
 
 	# List perf subcommands or long options
-	if [ $COMP_CWORD -eq 1 ]; then
+	if [ $cword -eq 1 ]; then
 		if [[ $cur == --* ]]; then
 			COMPREPLY=( $( compgen -W '--help --version \
 			--exec-path --html-path --paginate --no-pager \
@@ -110,13 +110,13 @@ _perf()
 			COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
 		fi
 	# List possible events for -e option
-	elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then
+	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
 		COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) )
 		__ltrim_colon_completions $cur
 	# List long option names
 	elif [[ $cur == --* ]];  then
-		subcmd=${COMP_WORDS[1]}
+		subcmd=${words[1]}
 		opts=$($cmd $subcmd --list-opts)
 		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
 	fi

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2013-10-15  5:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-04 12:41 [PATCH 0/7] Minor perf completion improvements Ramkumar Ramachandra
2013-07-04 12:41 ` [PATCH 1/7] perf completion: don't dictate perf install location Ramkumar Ramachandra
2013-10-15  5:22   ` [tip:perf/core] perf completion: Don' t " tip-bot for Ramkumar Ramachandra
2013-07-04 12:41 ` [PATCH 2/7] perf completion: update __ltrim_colon_completions Ramkumar Ramachandra
2013-10-15  5:22   ` [tip:perf/core] perf completion: Update __ltrim_colon_completions tip-bot for Ramkumar Ramachandra
2013-07-04 12:41 ` [PATCH 3/7] perf completion: strip dependency on _filedir Ramkumar Ramachandra
2013-10-15  5:23   ` [tip:perf/core] perf completion: Strip " tip-bot for Ramkumar Ramachandra
2013-07-04 12:41 ` [PATCH 4/7] perf completion: modernize style Ramkumar Ramachandra
2013-07-16 17:19   ` Arnaldo Carvalho de Melo
2013-07-16 17:22     ` Ramkumar Ramachandra
2013-08-07 20:26       ` Arnaldo Carvalho de Melo
2013-08-08  4:19         ` Ramkumar Ramachandra
2013-09-18 23:31         ` Ramkumar Ramachandra
2013-07-04 12:41 ` [PATCH 5/7] perf completion: strip function_exists () Ramkumar Ramachandra
2013-10-15  5:23   ` [tip:perf/core] perf completion: Strip " tip-bot for Ramkumar Ramachandra
2013-07-04 12:41 ` [PATCH 6/7] perf completion: strip dependency on bash-completion Ramkumar Ramachandra
2013-10-15  5:23   ` [tip:perf/core] perf completion: Strip " tip-bot for Ramkumar Ramachandra
2013-07-04 12:41 ` [PATCH 7/7] perf completion: use more comp words Ramkumar Ramachandra
2013-10-15  5:23   ` [tip:perf/core] perf completion: Use " tip-bot for Ramkumar Ramachandra
2013-07-05  2:46 ` [PATCH 0/7] Minor perf completion improvements Namhyung Kim
2013-07-05 10:03   ` Ramkumar Ramachandra
2013-07-15  7:51 ` Ramkumar Ramachandra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).