Prototype: islink(filename)

Return type: boolean

Description: Returns whether the named object filename is a symbolic link.

The link node must both exist and be a symbolic link. Hard links cannot be detected using this function.

Notes:

  • islink() does not resolve symlinks as part of it's test. If a broken symlink exists, the file is still seen to be a symlink. Use filestat("myfile", "link target") to see if a file resolves to a the expected target, and check if the link target exists. Alternatively use test with returnszero(), for example returnszero("/bin/test -f myfile").

Arguments:

  • filename: string - File object name - in the range: "?(/.*)

Example:

Prepare:

code
ln -fs /tmp/cfe_testhere.txt /tmp/link

Run:

code
body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  classes:

      "islink" expression => islink("/tmp/link");

  reports:

    islink::

      "It's a link.";

}

Output:

code
R: It's a link.

See also: fileexists(), filestat(), isdir(), isplain(), returnszero()