problems with PATTERN/LINE in ainsl(1)

Darshaka Pathirana dpat at syn-net.org
Wed Sep 30 02:32:11 CEST 2009


Hi!

I have something like this:

<file>
#! /bin/sh
ainsl -a $target/etc/sudoers "%adm ALL = NOPASSWD: /bin/su -[mp]"
exit 0
</file>

Got the expected output (in /etc/sudoers without LINE):

  %adm ALL = NOPASSWD: /bin/su -[mp]

Running again (now containing LINE) leads to:

  %adm ALL = NOPASSWD: /bin/su -[mp]
  %adm ALL = NOPASSWD: /bin/su -[mp]

(I obviously exptected no adding..)

I then tried:

ainsl -a $target/etc/sudoers "%adm ALL = NOPASSWD: /bin/su -\[mp\]"

Output (without LINE):

  %adm ALL = NOPASSWD: /bin/su -\[mp\]

Second run (now with LINE):
  %adm ALL = NOPASSWD: /bin/su -\[mp\]
  %adm ALL = NOPASSWD: /bin/su -\[mp\]

Quoting man ainsl(1):

,----
| If  PATTERN  is  not given, LINE is used instead for matching a line
| in FILE.  Then LINE may also contain the anchors ’^’ and ’$’ which
| are only treated specialy  at  the beginning or end of the pattern
| and are used for matching, not when adding  the  line.  Additionaly,
| the  following characters are escaped in LINE: ( ) +
`----

It has something to do with '[' and ']' (it works fine without these
characters) but nothing is mentioned in the man-page.

Any hints or is this a bug?

Greetings,
 - Darsha



More information about the linux-fai mailing list