-
Notifications
You must be signed in to change notification settings - Fork 68
[AESH-456] Append the content to the file with name tmp|file results to 'tmp\|file' being created #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AESH-456] Append the content to the file with name tmp|file results to 'tmp\|file' being created #282
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,7 +198,13 @@ else if (parseCurlyAndSquareBrackets && (c == CURLY_END || c == PARENTHESIS_END) | |
handleCurlyEnd(c); | ||
} | ||
else if (haveEscape) { | ||
builder.append(BACK_SLASH); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems that the \ shouldn't be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I understand the previous comments the addition of \ should be replaced by the lines 201-207. Which add the \ when it is not escaping an operator:
Otherwise the \ would be inserted 2 times in case it is not escaping an operator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MMarus , I read too quickly and thought that it was the other parse method. Forget about this comment. |
||
//Escaping an operator? | ||
if (!isQuoted() | ||
&& (currentOperator = matchesOperators(operators, text, index)) != OperatorType.NONE) { | ||
// Do not add the \ that was a way to escape an operator. | ||
} else { | ||
builder.append(BACK_SLASH); | ||
} | ||
builder.append(c); | ||
haveEscape = false; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.aesh.parser; | ||
|
||
import org.aesh.command.operator.OperatorType; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Marek Marusic <mmarusic@redhat.com> on 2/19/18. | ||
*/ | ||
public class ParsedLineTest { | ||
@Test | ||
public void firstWordFromEmptyLine() throws Exception { | ||
List<ParsedWord> words = new ArrayList<>(); | ||
ParsedLine pl = new ParsedLine("", words, -1, | ||
0, 0, ParserStatus.OK, "", OperatorType.NONE); | ||
assertEquals(pl.firstWord().word(), ""); | ||
} | ||
|
||
@Test | ||
public void firstWordFromLineWithWords() throws Exception { | ||
List<ParsedWord> words = new ArrayList<>(); | ||
words.add(new ParsedWord("command", 0)); | ||
words.add(new ParsedWord("line", 1)); | ||
words.add(new ParsedWord("text", 2)); | ||
|
||
ParsedLine pl = new ParsedLine("command line text", words, -1, | ||
0, 0, ParserStatus.OK, "", OperatorType.NONE); | ||
assertEquals(pl.firstWord().word(), "command"); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment. I would love ;-), to have the 2 parsing operations be merged in order to avoid to duplicate fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably look at trying to refactor that method so it could be inlined...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MMarus , I will try to spend some time (once your fixed is merged) to refactor the 2 methods.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have incorporated the changes you suggested into the PR. However, I didn't refactor the 2 methods in order to keep the PR cleaner. I am not sure why the github ignores changes I made here and still requests a change.