query
On this page

baseNameOf

builtins.baseNameOf

Primop
Docs pulled from | This Revision | 1 day ago

Takes 1 arguments

x


Return the base name of either a path value x or a string x, depending on which type is passed, and according to the following rules.

For a path value, the base name is considered to be the part of the path after the last directory separator, including any file extensions. This is the simple case, as path values don't have trailing slashes.

When the argument is a string, a more involved logic applies. If the string ends with a /, only this one final slash is removed.

After this, the base name is returned as previously described, assuming / as the directory separator. (Note that evaluation must be platform independent.)

This is somewhat similar to the GNU basename command, but GNU basename will strip any number of trailing slashes.

This function is not defined in a .nix file. It is likely a builtins function or an alias of a builtins function. builtins functions are predefined functions provided by Nix.

Noogle detected

Detected Type
baseNameOf :: String -> String

Implementation

This function is implemented in c++ and is part of the native nix runtime.