dundalek / closh

Bash-like shell based on Clojure
Eclipse Public License 1.0
1.61k stars 65 forks source link

Symlink to scripts in resources #95

Closed jeroenvandijk closed 5 years ago

jeroenvandijk commented 5 years ago

This is an example of the scripts could be packaged in the jar to tackle #92

It doesn't really work yet. Maybe scripts need to be copied from the resources jar or the way the scripts are loaded need to change.

with a new uberjar based on this branch:

$ (setenv "CLOSH_SOURCES_PATH" "jar:file:/Users/jeroen/bin/closh/target/project.jar!")
$ (ifOct 09, 2018 12:37:22 PM org.jline.utils.Log logr
INFO: Error while finding completion candidates
java.io.IOException: Cannot run program "jar:file:/Users/jeroen/bin/closh/target/project.jar!/scripts/completion/completion.fish" (in directory "/Users/jeroen/bin/closh"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at closh.zero.platform.process$shx.invokeStatic(process.clj:88)

The file is actually readable though via clojure:

$ (slurp "jar:file:/Users/jeroen/bin/closh/target/project.jar!/scripts/completion/completion.fish")
"#!/usr/bin/env fish\n\ncomplete --do-complete=$argv\n"
jeroenvandijk commented 5 years ago

A more generic way of setting the CLOSH_SOURCES_PATH:

 (setenv "CLOSH_SOURCES_PATH" (.replace (str (clojure.java.io/resource "scripts")) "/scripts" ""))