From 70543fc1ef9733fb754cecda96805349cb36de32 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 21 Dec 2024 15:13:05 -0400 Subject: Add shebangs and x bit to executables With run.sh, we can build and run the file in one go. This means we can also use it as an interpreter in a shebang line and properly use the Unix executable bit. This is pretty cool and gives a few advantages: running any executable file is just `exec file.hs` or even `./file.hs`, finding all executables is `fd -t x`, you don't need to specify or know an `out` name to run something, execution of a program is standardized. There is a hack to get this to work. In C and Common Lisp, `#!` is illegal syntax, so I had to use shell syntax to invoke run.sh, call it on the current file, and then exit the shell script. Meanwhile, run.sh takes the file and evals the whole thing, building and running it. As long as either `//` or `;` is a comment character in the target language, then this works. Maybe a better thing to do would be to pre-process the file and remove the `#!` before passing it to the C compiler, like [ryanmjacobs/c][1] and [tcc][2]? However this won't work in Lisp because then I can't just load the file directly into the repl, so maybe the comment hack needs to stay. [1]: https://github.com/ryanmjacobs/c/tree/master [2]: https://repo.or.cz/tinycc.git/blob/HEAD:/tccrun.c --- Biz/Dragons.hs | 1 + Biz/Dragons/Analysis.hs | 1 + Biz/Dragons/main.py | 1 + Biz/Que/Client.py | 1 + Biz/Que/Host.hs | 1 + Biz/Que/Site.hs | 1 + Biz/Storybook.py | 1 + 7 files changed, 7 insertions(+) mode change 100644 => 100755 Biz/Dragons.hs mode change 100644 => 100755 Biz/Dragons/Analysis.hs mode change 100644 => 100755 Biz/Dragons/main.py mode change 100644 => 100755 Biz/Que/Client.py mode change 100644 => 100755 Biz/Que/Host.hs mode change 100644 => 100755 Biz/Que/Site.hs mode change 100644 => 100755 Biz/Storybook.py (limited to 'Biz') diff --git a/Biz/Dragons.hs b/Biz/Dragons.hs old mode 100644 new mode 100755 index 3379732..7ba7fa0 --- a/Biz/Dragons.hs +++ b/Biz/Dragons.hs @@ -1,3 +1,4 @@ +#!/usr/bin/env run.sh {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} diff --git a/Biz/Dragons/Analysis.hs b/Biz/Dragons/Analysis.hs old mode 100644 new mode 100755 index 64b2906..ef255fe --- a/Biz/Dragons/Analysis.hs +++ b/Biz/Dragons/Analysis.hs @@ -1,3 +1,4 @@ +#!/usr/bin/env run.sh {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE LambdaCase #-} diff --git a/Biz/Dragons/main.py b/Biz/Dragons/main.py old mode 100644 new mode 100755 index e9df03f..de84ff5 --- a/Biz/Dragons/main.py +++ b/Biz/Dragons/main.py @@ -1,3 +1,4 @@ +#!/usr/bin/env run.sh # : out dragons.py """Analyze developer allocation across a codebase.""" diff --git a/Biz/Que/Client.py b/Biz/Que/Client.py old mode 100644 new mode 100755 index ccbb980..7b28e27 --- a/Biz/Que/Client.py +++ b/Biz/Que/Client.py @@ -1,3 +1,4 @@ +#!/usr/bin/env run.sh # : out que # ruff: noqa: PERF203 """simple client for que.run.""" diff --git a/Biz/Que/Host.hs b/Biz/Que/Host.hs old mode 100644 new mode 100755 index a908d5b..834ce0e --- a/Biz/Que/Host.hs +++ b/Biz/Que/Host.hs @@ -1,3 +1,4 @@ +#!/usr/bin/env run.sh {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} diff --git a/Biz/Que/Site.hs b/Biz/Que/Site.hs old mode 100644 new mode 100755 index f4e4a9c..838ae52 --- a/Biz/Que/Site.hs +++ b/Biz/Que/Site.hs @@ -1,3 +1,4 @@ +#!/usr/bin/env run.sh {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} diff --git a/Biz/Storybook.py b/Biz/Storybook.py old mode 100644 new mode 100755 index c29d9f5..0c96ee7 --- a/Biz/Storybook.py +++ b/Biz/Storybook.py @@ -1,3 +1,4 @@ +#!/usr/bin/env run.sh """Storybook Generator Application. This application generates a children's storybook using the OpenAI API. -- cgit v1.2.3