about summary refs log tree commit diff
path: root/pkgs/profpatsch/execline
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2019-10-02 00:22:14 +0200
committerProfpatsch <mail@profpatsch.de>2019-10-02 00:23:03 +0200
commite9975c9a39cb4e654d9132de4b952f51174a0926 (patch)
tree6e2f4e3cb534b9cb84f11806a7a4d9a09ea806a4 /pkgs/profpatsch/execline
parent6043fbc005dc7ce810cacca6393ff469a6b75604 (diff)
pkgs/profpatsch: writeExecline, writeExeclineLocal
similar to writeScript, but writes an execline instead. Should be
upstreams to `lib.writers` sometimes.
Diffstat (limited to 'pkgs/profpatsch/execline')
-rw-r--r--pkgs/profpatsch/execline/write-execline.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkgs/profpatsch/execline/write-execline.nix b/pkgs/profpatsch/execline/write-execline.nix
new file mode 100644
index 00000000..721261a2
--- /dev/null
+++ b/pkgs/profpatsch/execline/write-execline.nix
@@ -0,0 +1,18 @@
+{ pkgs, execlineb-with-builtins }:
+let
+  escape = ./escape.nix { inherit (pkgs) lib; };
+
+  # Write a list of execline argv parameters to an execline script.
+  # Everything is escaped correctly.
+  # TODO upstream into nixpkgs
+  writeExeclineCommon = writer: name: { readNArgs ? 0 }: argList: writer name ''
+    #!${execlineb-with-builtins}/bin/execlineb -s${toString readNArgs}
+    export EXECLINE_STRICT 2
+    ${escape.escapeExecline argList}
+  '';
+  writeExecline = writeExeclineCommon pkgs.writeScript;
+  writeExeclineBin = writeExeclineCommon pkgs.writeScriptBin;
+
+in {
+  inherit writeExecline writeExeclineBin;
+}