summaryrefslogtreecommitdiff
path: root/xmake/core/base/string.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core/base/string.lua')
-rw-r--r--xmake/core/base/string.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua
index ad178895b..22a84d9f4 100644
--- a/xmake/core/base/string.lua
+++ b/xmake/core/base/string.lua
@@ -136,5 +136,17 @@ function string:less(other)
return string.strcmp(self, other) < 0
end
+-- try to format
+function string.tryformat(format, ...)
+
+ -- attempt to format it
+ local ok, str = pcall(string.format, format, ...)
+ if ok then
+ return str
+ else
+ return format
+ end
+end
+
-- return module: string
return string