about summary refs log tree commit diff
path: root/Src/Modules
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-02-25 11:15:26 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-02-25 11:15:26 +0000
commita3b971a27ec7ba78e0a6b0a248c619b8cec53d98 (patch)
treea9b209d3e63a7ea3cbeab3eea7fc607aeffef8d1 /Src/Modules
parentbec3de98dfab722b21e69a905bd83e4bfac22f72 (diff)
downloadzsh-a3b971a27ec7ba78e0a6b0a248c619b8cec53d98.tar.gz
zsh-a3b971a27ec7ba78e0a6b0a248c619b8cec53d98.tar.xz
zsh-a3b971a27ec7ba78e0a6b0a248c619b8cec53d98.zip
27755: add "zsystem supports" to zsh/system
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/system.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index ef1ebb0b0..93796128b 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -491,6 +491,35 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
 }
 
 
+/*
+ * Return status zero if the zsystem feature is supported, else 1.
+ * Operates silently for future-proofing.
+ */
+/**/
+static int
+bin_zsystem_supports(char *nam, char **args,
+		     UNUSED(Options ops), UNUSED(int func))
+{
+    if (!args[0]) {
+	zwarnnam(nam, "supports: not enough arguments");
+	return 255;
+    }
+    if (args[1]) {
+	zwarnnam(nam, "supports: too many arguments");
+	return 255;
+    }
+
+    /* stupid but logically this should work... */
+    if (!strcmp(*args, "supports"))
+	return 0;
+#ifdef HAVE_FCNTL_H
+    if (!strcmp(*args, "flock"))
+	return 0;
+#endif
+    return 1;
+}
+
+
 /**/
 static int
 bin_zsystem(char *nam, char **args, Options ops, int func)
@@ -498,6 +527,8 @@ bin_zsystem(char *nam, char **args, Options ops, int func)
     /* If more commands are implemented, this can be more sophisticated */
     if (!strcmp(*args, "flock")) {
 	return bin_zsystem_flock(nam, args+1, ops, func);
+    } else if (!strcmp(*args, "supports")) {
+	return bin_zsystem_supports(nam, args+1, ops, func);
     }
     zwarnnam(nam, "unknown subcommand: %s", *args);
     return 1;