diff options
author | Karl Berry <karl@freefriends.org> | 2023-09-13 20:38:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-09-13 20:38:34 +0000 |
commit | 8f22ac5379816e4b6bdd9e5c9dc981b4223187b4 (patch) | |
tree | 39e7970a9790e840dcb289f1b18ebbb5422245b9 | |
parent | 3f4602ec4797af5045e1c8ce882a67dba62007c8 (diff) |
runtexshebang (13sep23)
git-svn-id: svn://tug.org/texlive/trunk@68269 c570f23f-e606-0410-a88d-b1316a301751
3 files changed, 113 insertions, 14 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/runtexshebang/runtexshebang.lua b/Build/source/texk/texlive/linked_scripts/runtexshebang/runtexshebang.lua index 11240adfe06..670bdc2b33a 100755 --- a/Build/source/texk/texlive/linked_scripts/runtexshebang/runtexshebang.lua +++ b/Build/source/texk/texlive/linked_scripts/runtexshebang/runtexshebang.lua @@ -22,15 +22,61 @@ -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -- THE SOFTWARE. -if not ( #arg == 1 ) then - print("runtexshebang 20230909 v0.3") - print("") - print("Usage: runtexshebang [input.tex]") - os.exit(0) +NAME = "runtexshebang" +VERSION = "20230913 v0.4" +USAGE = [[ +Usage: runtexshebang [input.tex] + +Options: + -h, --help print help + -v, --version print version + +See also: +The command + texdoc runtexshebang +should give you access to the README. +]] + +function whoami() + print(NAME .. " " .. VERSION) end -local line_ctr = 0 -for line in io.lines(arg[1]) do +function help() + whoami() + print() + print(USAGE) +end + +if #arg == 0 then + help() + os.exit(0) +end + +-- +texfilename = "" +narg = 1 +repeat + this_arg = arg[narg] + -- replace double dash by single dash at the beginning + this_arg = string.gsub(this_arg, "^%-%-", "-") + + if this_arg == "-h" or this_arg == "-help" then + help() + os.exit(0) + elseif this_arg == "-v" or this_arg == "-version" then + whoami() + os.exit(0) + else + texfilename = this_arg + end --if this_arg == ... + narg = narg+1 +until narg > #arg + +-- main process +whoami() + +line_ctr = 0 +for line in io.lines(texfilename) do line_ctr = line_ctr + 1 if line_ctr > 20 then break end diff --git a/Master/texmf-dist/doc/support/runtexshebang/README.md b/Master/texmf-dist/doc/support/runtexshebang/README.md index e96825b9c18..7c3f233b2dd 100644 --- a/Master/texmf-dist/doc/support/runtexshebang/README.md +++ b/Master/texmf-dist/doc/support/runtexshebang/README.md @@ -158,8 +158,15 @@ You can typeset a LaTeX document file in a Docker container as below. ## References +### Commentary + * [TeXworks、TeXShop、VSCodeでTeX-style shebangしてみた - Qiita](https://qiita.com/munepi/items/a30c68133cfffbf4d189) (in Japanese) +### Tools supporting `%#!` + +* [YaTeX](https://www.yatex.org/): Yet Another TeX mode for Emacs +* [llmk](https://github.com/wtsnjp/llmk): Light LaTeX Make + Enjoy Happy TeXing! diff --git a/Master/texmf-dist/scripts/runtexshebang/runtexshebang.lua b/Master/texmf-dist/scripts/runtexshebang/runtexshebang.lua index 11240adfe06..670bdc2b33a 100755 --- a/Master/texmf-dist/scripts/runtexshebang/runtexshebang.lua +++ b/Master/texmf-dist/scripts/runtexshebang/runtexshebang.lua @@ -22,15 +22,61 @@ -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -- THE SOFTWARE. -if not ( #arg == 1 ) then - print("runtexshebang 20230909 v0.3") - print("") - print("Usage: runtexshebang [input.tex]") - os.exit(0) +NAME = "runtexshebang" +VERSION = "20230913 v0.4" +USAGE = [[ +Usage: runtexshebang [input.tex] + +Options: + -h, --help print help + -v, --version print version + +See also: +The command + texdoc runtexshebang +should give you access to the README. +]] + +function whoami() + print(NAME .. " " .. VERSION) end -local line_ctr = 0 -for line in io.lines(arg[1]) do +function help() + whoami() + print() + print(USAGE) +end + +if #arg == 0 then + help() + os.exit(0) +end + +-- +texfilename = "" +narg = 1 +repeat + this_arg = arg[narg] + -- replace double dash by single dash at the beginning + this_arg = string.gsub(this_arg, "^%-%-", "-") + + if this_arg == "-h" or this_arg == "-help" then + help() + os.exit(0) + elseif this_arg == "-v" or this_arg == "-version" then + whoami() + os.exit(0) + else + texfilename = this_arg + end --if this_arg == ... + narg = narg+1 +until narg > #arg + +-- main process +whoami() + +line_ctr = 0 +for line in io.lines(texfilename) do line_ctr = line_ctr + 1 if line_ctr > 20 then break end |