Skip to content

Commit b5159df

Browse files
committed
Revert "ExtendedDefaultParser should not add empty arguments"
This reverts commit c1c9f5e. Relates #765
1 parent c1c9f5e commit b5159df

File tree

2 files changed

+7
-62
lines changed

2 files changed

+7
-62
lines changed

spring-shell-core/src/main/java/org/springframework/shell/jline/ExtendedDefaultParser.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2023 the original author or authors.
2+
* Copyright 2017-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -125,26 +125,23 @@ else if (!isEscapeChar(line, i)) {
125125
}
126126
}
127127

128-
if (current.length() > 0 || (line != null && cursor == line.length())) {
129-
if (current.length() > 0) {
130-
words.add(current.toString());
131-
}
128+
if (current.length() > 0 || cursor == line.length()) {
129+
words.add(current.toString());
132130
}
133131

134-
if (line != null && cursor == line.length() && words.size() > 0) {
132+
if (cursor == line.length()) {
135133
wordIndex = words.size() - 1;
136134
wordCursor = words.get(words.size() - 1).length();
137135
}
138136

139-
if (eofOnEscapedNewLine && (line != null && isEscapeChar(line, line.length() - 1))) {
137+
if (eofOnEscapedNewLine && isEscapeChar(line, line.length() - 1)) {
140138
throw new EOFError(-1, -1, "Escaped new line", "newline");
141139
}
142140
if (eofOnUnclosedQuote && quoteStart >= 0 && context != ParseContext.COMPLETE) {
143-
throw new EOFError(-1, -1, "Missing closing quote",
144-
(line != null && line.charAt(quoteStart) == '\'') ? "quote" : "dquote");
141+
throw new EOFError(-1, -1, "Missing closing quote", line.charAt(quoteStart) == '\'' ? "quote" : "dquote");
145142
}
146143

147-
String openingQuote = (quoteStart >= 0 && line != null) ? line.substring(quoteStart, quoteStart + 1) : null;
144+
String openingQuote = quoteStart >= 0 ? line.substring(quoteStart, quoteStart + 1) : null;
148145
return wrap(new ExtendedArgumentList(line, words, wordIndex, wordCursor, cursor, openingQuote));
149146
}
150147

spring-shell-core/src/test/java/org/springframework/shell/jline/ExtendedDefaultParserTests.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)