add script-interpreter
This commit is contained in:
parent
4d0a87386e
commit
5b510c550d
14
script-interpreter.nix
Normal file
14
script-interpreter.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
with builtins;
|
||||||
|
|
||||||
|
let file-lines = import ./file-lines.nix; in
|
||||||
|
|
||||||
|
f: ( let n = head (split-filename f); in
|
||||||
|
let
|
||||||
|
lines = file-lines f;
|
||||||
|
firstLine = head lines;
|
||||||
|
shebangMatch = match ''#! *(.*[/])?(([\][ ]|[^ /])*)( (.*))?'' firstLine;
|
||||||
|
in
|
||||||
|
if shebangMatch == null
|
||||||
|
then rec { interpreter = "sh"; args = "";}
|
||||||
|
else rec { interpreter = (elemAt shebangMatch 1); args = (elemAt shebangMatch 4);}
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user