You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Jamie goodyear (JIRA)" <ji...@apache.org> on 2011/07/12 15:45:00 UTC

[jira] [Closed] (KARAF-134) The sort command does not work when trying to sort on the last field

     [ 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