about summary refs log tree commit diff
path: root/pkgs/profpatsch/execline/write-execline.nix
blob: c2128ea3e89fcdb14570e810a0e04a0a356393b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{ pkgs, execlineb-with-builtins }:
let
  escape = import ./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 -Ws${toString readNArgs}
    ${escape.escapeExecline argList}
  '';
  writeExecline = writeExeclineCommon pkgs.writeScript;
  writeExeclineBin = writeExeclineCommon pkgs.writeScriptBin;

in {
  inherit writeExecline writeExeclineBin;
}