-
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
Conversation
config.setArgument(pl.line().trim()); | ||
ParsedLineIterator iterator = pl.iterator(); | ||
String word = iterator.hasNextWord() ? iterator.pollWord() : ""; | ||
config.setArgument(word); |
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.
pl.line() did contain unparsed content of the line. Therefore I used the first word from the ParsedLine and the rest is ignored (same behaviour can be observed in bash while running "echo version >> tmp|file anotherWord".
Do you think this is good practise or it would be better to iterate over all the words and use all of them as an argument separated by white space?
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.
@jfdenise what do you think? The argument should only be one word afaik. It should be sufficient to call pl.lastWord() i think.
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 looked at the bash operator, actually it can be located anywhere in the command.
For ex: > foo.txt echo bar or echo > foo.txt bar are identical.
aesh syntax doesn't support this and I think that we shouldn't this is not at all intuitive.
In this case we should get the next world and ignore the following words as it is suggested.
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 , you should log a bug against aesh, link the WFCORE-3554 issue to the aesh one and have the commit message to reference the aesh issue. It will be simpler to track aesh component upgrade.
Thanks.
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.
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.
Hi, thanks for the pr. I just went on PTO, but I'll try to review it asap.
handleCurlyEnd(c); | ||
} | ||
else if (haveEscape) { | ||
builder.append(BACK_SLASH); |
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 think that this change impacts goes further than the fix. Any \ character contained in non quoted text is removed by the parser. I don't think tha tthis is what we want. My understanding is as follow:
- Use \ to escape a space character. In this case the \ character is removed but no new word is created.
- Any other usages, the \ character is kept.
The reported problem shows that we need to offer a way to escape operators too and have the \ be removed from the parsed content in this case.
So I think that the fix should be narrower, something like:
else if (haveEscape) {
//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;
}
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.
ah, i missed this. good catch @jfdenise, yes we need this change.
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.
In this method there are no operators, so I just did undu the deletion of the backslash insertion.
handleCurlyEnd(c); | ||
} | ||
else if (haveEscape) { | ||
builder.append(BACK_SLASH); |
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.
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.
6a37d48
to
d57fbb6
Compare
@MMarus , would you mind to squash the 2 commits, this makes review simpler. Thank-you. |
…to 'tmp\|file' being created
d57fbb6
to
1848f65
Compare
Yes, of course it's not a problem :). Thank You for your reviews. |
handleCurlyEnd(c); | ||
} | ||
else if (haveEscape) { | ||
builder.append(BACK_SLASH); |
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.
Seems that the \ shouldn't be removed.
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.
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:
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);
}
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 comment
The 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.
thanks! |
AESH: https://issues.jboss.org/browse/AESH-456
WFCORE: https://issues.jboss.org/browse/WFCORE-3554