David Lutterkort <[email protected]> wrote on 02/21/2011 03:29:21 PM:
> On Thu, 2011-02-17 at 14:52 -0600, [email protected] wrote: > > The other suggests a hack of using a zero-padded number to append entries > > to the list, > > This is not a hack - that is the recommended way to generate a label > that is guaranteed to be different from all the others in a numbered > sequence (even though I said number there, Augeas only knows strings) I was just repeating his wording.. i did note that the augeas documentation recommend this method. > > I don't see how the ins method would work unless you know the number of > > the last entry. > > Path expressions to the rescue: > > ins 01 after /files/etc/fstab/*[last()] > > meaning 'insert the node 01 as the last child of /files/etc/fstab' ahh i was missing the *[] bit in my playing. > > And to be quite honest, I can't figure out how to use > > insert to add a sequential entry anyway. When I tried 'ins 7 > > after /files/etc/fstab/6' I just got a 7 that was an entry not a node. > > Using 'set /files/etc/fstab/7/file /path' I get what I'm expecting. > > You actually don't even need to bother with 'ins'. When you set the > value of a node that does not exist yet, it is automatically created. > The new node is always the last of its siblings, so that the following > will append the node '01' to the existing ones under /files/etc/fstab: > > defvar fstab /files/etc/fstab > set $fstab/01/spec /dev/voo/doo > set $fstab/01/file /voo/doo > set $fstab/01/vfstype voodoo > set $fstab/01/opt defaults > set $fstab/01/dump 0 > set $fstab/01/passno 0 > save > > Of course, when Augeas reads this back in, the '01' will be changed to > something else, maybe '8' - to make the above idempotent you have to > check, for example, if a node matching this path expression exists: > > /files/etc/fstab/*[spec = '/dev/voo/doo'] > > > The blog commenter's change from seq to label seems to work, and seems to > > be the more intuitive and effective method, but it requires a change to the > > lens and API for that file that would likely cause regression issues. > > Read Francis' high praise of seq from the other day ;) I don't think > changing the fstab lens is really desirable. thank you very much for the reply. -greg _______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
