Mercurial > vim
diff runtime/doc/builtin.txt @ 28629:5ef46b938c6e v8.2.4838
patch 8.2.4838: checking for absolute path is not trivial
Commit: https://github.com/vim/vim/commit/dca1d40cd0f2af0755519e7028378bd3c8fefd31
Author: LemonBoy <thatlemon@gmail.com>
Date: Thu Apr 28 15:26:33 2022 +0100
patch 8.2.4838: checking for absolute path is not trivial
Problem: Checking for absolute path is not trivial.
Solution: Add isabsolutepath(). (closes https://github.com/vim/vim/issues/10303)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 28 Apr 2022 16:30:03 +0200 |
parents | 4d76b3e07c07 |
children | e4de5b5193b4 |
line wrap: on
line diff
--- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -295,6 +295,7 @@ inputsecret({prompt} [, {text}]) String insert({object}, {item} [, {idx}]) List insert {item} in {object} [before {idx}] interrupt() none interrupt script execution invert({expr}) Number bitwise invert +isabsolutepath({path}) Number |TRUE| if {path} is an absolute path isdirectory({directory}) Number |TRUE| if {directory} is a directory isinf({expr}) Number determine if {expr} is infinity value (positive or negative) @@ -4672,6 +4673,24 @@ invert({expr}) *invert()* < Can also be used as a |method|: > :let bits = bits->invert() +isabsolutepath({directory}) *isabsolutepath()* + The result is a Number, which is |TRUE| when {path} is an + absolute path. +< On Unix, a path is considered absolute when it starts with '/'. + On MS-Windows, it is considered absolute when it starts with an + optional drive prefix and is followed by a '\' or '/'. UNC paths + are always absolute. + Example: > + echo isabsolutepath('/usr/share/') " 1 + echo isabsolutepath('./foobar') " 0 + echo isabsolutepath('C:\Windows') " 1 + echo isabsolutepath('foobar') " 0 + echo isabsolutepath('\\remote\file') " 1 + + Can also be used as a |method|: > + GetName()->isabsolutepath() + + isdirectory({directory}) *isdirectory()* The result is a Number, which is |TRUE| when a directory with the name {directory} exists. If {directory} doesn't