karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jamie goodyear (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (KARAF-134) The sort command does not work when trying to sort on the last field
Date Tue, 12 Jul 2011 13:45:00 GMT

     [ https://issues.apache.org/jira/browse/KARAF-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jamie goodyear closed KARAF-134.
--------------------------------


> The sort command does not work when trying to sort on the last field
> --------------------------------------------------------------------
>
>                 Key: KARAF-134
>                 URL: https://issues.apache.org/jira/browse/KARAF-134
>             Project: Karaf
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>             Fix For: 2.1.0
>
>
> The command 
> {code}
> packages:exports  | sort -t "\)" -k 2
> {code}
> does not work.
> The patch is easy, but i'd like a unit test before committing it.
> {code}
> diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/SortAction.java
b/shell/commands/src/main/java/org/apache/karaf/shell/commands/SortAction.java
> index 758df96..27452cd 100644
> --- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/SortAction.java
> +++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/SortAction.java
> @@ -233,7 +233,7 @@ public class SortAction extends OsgiCommandSupport {
>          protected int[] getSortKey(String str, List<Integer> fields, Key key)
{
>              int start;
>              int end;
> -            if (key.startField * 2 < fields.size()) {
> +            if (key.startField * 2 <= fields.size()) {
>                  start = fields.get((key.startField - 1) * 2);
>                  if (key.ignoreBlanksStart) {
>                      while (start < fields.get((key.startField - 1) * 2 + 1) &&
Character.isWhitespace(str.charAt(start))) {
> @@ -246,7 +246,7 @@ public class SortAction extends OsgiCommandSupport {
>              } else {
>                  start = 0;
>              }
> -            if (key.endField > 0 && key.endField * 2 < fields.size())
{
> +            if (key.endField > 0 && key.endField * 2 <= fields.size())
{
>                  end =  fields.get((key.endField - 1) * 2);
>                  if (key.ignoreBlanksEnd) {
>                      while (end < fields.get((key.endField - 1) * 2 + 1) &&
Character.isWhitespace(str.charAt(end))) {
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message