Skip to content
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

last() does not work inside of following-sibling or preceding-sibling #317

Open
asasfu opened this issue Nov 20, 2015 · 1 comment
Open

Comments

@asasfu
Copy link

asasfu commented Nov 20, 2015

last() does not resolve when used inside following-sibling or preceding-sibling.(it effectively resolves to 1 I believe in this case)

augtool print /files/etc/pam.d/password-auth/"*[type='auth'][following-sibling::*[type='auth'][last()]]" != augtool print /files/etc/pam.d/password-auth/"*[type='auth'][following-sibling::*[type='auth'][6]]" (if 6 is your last item in password-auth's auth section)

I'd submit a PR for it but alas I only write Ruby and Java...

@lutter
Copy link
Member

lutter commented Nov 24, 2015

I don't follow what this path expression is trying to do. Here's some explanation on what it says:

  • /files/etc/pam.d/password-auth/*[type='auth'] are all nodes (~ lines IIRC) in password-auth who have a type child with value auth
  • adding [following-sibling::*[type='auth'][last()]] to that keeps only those nodes who have a sibling later on that also has a type child with value auth; the [last()] there doesn't really do anything -if we have any matching following siblings [last()] will always match
  • adding [following-sibling::*[type='auth'][6]] to the first expression keeps those nodes who have 6 or more following siblings with a type child with value auth

I wonder whether what was meant was

/files/etc/pam.d/password-auth/"*[type='auth'][following-sibling::*[type='auth']][last()]

which roughly says "Of all the type=auth nodes give me the last one that has a following type=auth sibling"; IOW, "Give me the last-but-one type=auth node" which could be written more concisely as

/files/etc/pam.d/password-auth/"*[type='auth'][last()-1]

But as I said, I am not sure what this expression is trying to achieve, so that suggestion might be wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants