handle arguments to the #!nix-shell directive

This commit is contained in:
2023-07-04 10:02:58 +00:00
parent 9119b2ebca
commit c45767a005
3 changed files with 173 additions and 6 deletions

View File

@@ -11,5 +11,29 @@ echo "hello, world!"
(first_line)
(next_line
(annotation_line
(nix_shell_args)))
(nix_shell_args
(interpreter
(sh_arg)))))
(next_line))
==================
nix-shell with interspersed payload
==================
#!/usr/bin/env nix-shell
echo hello
echo again
#!nix-shell -i bash
echo everybody
---
(source_file
(first_line)
(next_line)
(next_line)
(next_line
(annotation_line
(nix_shell_args
(interpreter
(sh_arg)))))
(next_line))

View File

@@ -1,5 +1,5 @@
==================
Minimal nix-shell invocation
minimal nix-shell invocation with interpreter
==================
#!/usr/bin/env nix-shell
@@ -10,4 +10,115 @@ Minimal nix-shell invocation
(first_line)
(next_line
(annotation_line
(nix_shell_args))))
(nix_shell_args
(interpreter
(sh_arg))))))
==================
non-interpreter argument
==================
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p gnused
---
(source_file
(first_line)
(next_line
(annotation_line
(nix_shell_args
(interpreter
(sh_arg))
(sh_arg)
(sh_arg)))))
==================
non-interpreter flags
==================
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p gnused awk
---
(source_file
(first_line)
(next_line
(annotation_line
(nix_shell_args
(interpreter
(sh_arg))
(sh_arg)
(sh_arg)
(sh_arg)))))
==================
quoted arguments
==================
#!/usr/bin/env nix-shell
#!nix-shell -i bash arg\ one 'arg"Two' "'argThree"
---
(source_file
(first_line)
(next_line
(annotation_line
(nix_shell_args
(interpreter
(sh_arg))
(sh_arg)
(sh_arg)
(sh_arg)))))
==================
order-independent
==================
#!/usr/bin/env nix-shell
#!nix-shell -p gnused -i bash
---
(source_file
(first_line)
(next_line
(annotation_line
(nix_shell_args
(sh_arg)
(sh_arg)
(interpreter
(sh_arg))))))
==================
empty nix-shell
==================
#!/usr/bin/env nix-shell
#!nix-shell
---
(source_file
(first_line)
(next_line
(annotation_line)))
==================
multiple annotation lines
==================
#!/usr/bin/env nix-shell
#!nix-shell -p gnused
#!nix-shell -i bash
---
(source_file
(first_line)
(next_line
(annotation_line
(nix_shell_args
(sh_arg)
(sh_arg))))
(next_line
(annotation_line
(nix_shell_args
(interpreter
(sh_arg))))))