{"id":13442629,"url":"https://github.com/SquircleSpace/shcl","last_synced_at":"2025-03-20T14:31:40.331Z","repository":{"id":149290993,"uuid":"70868204","full_name":"SquircleSpace/shcl","owner":"SquircleSpace","description":"SHell in Common Lisp","archived":false,"fork":false,"pushed_at":"2021-05-11T07:03:39.000Z","size":886,"stargazers_count":311,"open_issues_count":17,"forks_count":16,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-05-19T05:36:12.145Z","etag":null,"topics":["common-lisp","shell"],"latest_commit_sha":null,"homepage":null,"language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SquircleSpace.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-14T02:52:45.000Z","updated_at":"2024-05-07T21:02:09.000Z","dependencies_parsed_at":"2023-09-03T13:25:09.940Z","dependency_job_id":null,"html_url":"https://github.com/SquircleSpace/shcl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquircleSpace%2Fshcl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquircleSpace%2Fshcl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquircleSpace%2Fshcl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquircleSpace%2Fshcl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SquircleSpace","download_url":"https://codeload.github.com/SquircleSpace/shcl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244630217,"owners_count":20484338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["common-lisp","shell"],"created_at":"2024-07-31T03:01:48.267Z","updated_at":"2025-03-20T14:31:39.972Z","avatar_url":"https://github.com/SquircleSpace.png","language":"Common Lisp","funding_links":[],"categories":["Common Lisp"],"sub_categories":[],"readme":"#+BEGIN_COMMENT\nCopyright 2017 Bradley Jensen\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n#+END_COMMENT\n\n#+TITLE: SHCL: Shell Meets Common Lisp\n#+AUTHOR: Brad Jensen\n\nSHCL is\n1. a very customizable shell made with secret alien technology, and\n2. an unholy union of POSIX Shell and Common Lisp.\n\nSHCL is more than just a shell.  It is a mutual embedding of POSIX\nShell and Common Lisp.  Behold Common Lisp embedded in POSIX shell\nembedded in Common Lisp!  Notice that the Common Lisp form embedded in\nthe shell expression can access the lexical environment.\n#+BEGIN_EXAMPLE\n(let ((rld \"rld\"))\n  (capture (:stdout)\n    #$ echo Hello ,(concatenate 'string \"Wo\" rld) #$))\n; =\u003e \"Hello World\"\n#+END_EXAMPLE\n\nNow lay your eyes on a lisp function participating in a pipeline!\n#+BEGIN_EXAMPLE\nshcl\u003e : ,(shcl/core/debug:graph-dependencies) | dot -Tpng \u003e graph.png\n#+END_EXAMPLE\n\nThe =#$= reader macro isn't just some hack that constructs a string to\nbe evaluated by a \"real\" shell.  The =#$= reader macro fully parses\nthe shell expression and constructs an equivalent Common Lisp form.\nSHCL IS the \"real\" shell!\n\n#+BEGIN_EXAMPLE\nSHCL/CORE/LISP-INTERPOLATION\u003e (macroexpand-1 '#$ if true; then echo woo; fi #$)\n(SHCL/CORE/SHELL-FORM:SHELL-IF\n (SHCL/CORE/SHELL-FORM:SHELL-RUN\n  (WITH-FD-STREAMS NIL\n    (EXPANSION-FOR-WORDS (LIST #\u003cNAME \"true\"\u003e) :EXPAND-ALIASES T\n                         :EXPAND-PATHNAME-WORDS T :SPLIT-FIELDS NIL))\n  :ENVIRONMENT-CHANGES NIL :FD-CHANGES NIL)\n (SHCL/CORE/SHELL-FORM:SHELL-RUN\n  (WITH-FD-STREAMS NIL\n    (EXPANSION-FOR-WORDS (LIST #\u003cNAME \"echo\"\u003e #\u003cNAME \"woo\"\u003e) :EXPAND-ALIASES T\n                         :EXPAND-PATHNAME-WORDS T :SPLIT-FIELDS NIL))\n  :ENVIRONMENT-CHANGES NIL :FD-CHANGES NIL))\nT\n#+END_EXAMPLE\n\n* Building SHCL\n\nSHCL is only really tested against SBCL and CCL, but it should be\nportable to other lisp compilers.  Be aware that ECL is known to be\nproblematic because it tries to reap child processes automatically.\n\nFirst, you'll need to install some dependencies.  To start with,\nyou'll need Clang and libedit.  There's also some Common Lisp\ndependencies that need to be taken care of: SBCL, Quicklisp, and\ncffi-grovel.  If you're new to building Common Lisp projects, you\nmight want to let [[https://github.com/roswell/roswell][Roswell]] set up your lisp environment for you.\n\n#+BEGIN_EXAMPLE\n# Set up Clang, libedit, and Roswell\nmake LISP='ros -s cffi-grovel run --'\n#+END_EXAMPLE\n\nYou can skip Roswell if you want.  Just make sure that you set ~LISP~\nto a command that runs SBCL with Quicklisp and cffi-grovel loaded.\nFor example,\n\n#+BEGIN_EXAMPLE\n# Set up Clang, libedit, SBCL, and Quicklisp\nQUICKLISP_SETUP=~/quicklisp/setup.lisp # or wherever you installed quicklisp\nmake LISP=\"sbcl --no-userinit --load \\\"$QUICKLISP_SETUP\\\" --eval '(ql:quickload :cffi-grovel)'\"\n#+END_EXAMPLE\n\nIf you use the Nix package manager, building SHCL is super easy!  SHCL\nhas a =default.nix= file, so you just need to run =nix-build=.\n#+BEGIN_EXAMPLE\nnix-build\n#+END_EXAMPLE\n\nCongratulations!  You built SHCL!  If you try to run =shcl= you'll\nprobably find that it doesn't work because it can't find\n=libshcl-support=.  As part of the build, SHCL produces a shared\nlibrary named (you guessed it!) =libshcl-support=.  That library needs\nto be installed somewhere that the dynamic linker can find it.  So, go\nahead and use =sudo make install= to install SHCL and its support\nlibrary!  Don't forget to set the =PREFIX= to something you're happy\nwith.  Alternatively, you can just use the =run-shcl= script included\nin the repository.  =run-shcl= just adds =$(pwd)= to the dynamic\nlinker's search path before invoking =./shcl=.\n\nNote: if you build SHCL using =nix-build=, then you don't have to\nworry about =libshcl-support=.  SHCL will know how to find it!\n\n* Example Usage\n\nI don't know what you're expecting to see here.  Its a POSIX-like\nshell.  You can do (almost) all your normal POSIX shell stuff in it.\n\n#+BEGIN_EXAMPLE\nshcl\u003e echo foobar\nfoobar\nshcl\u003e { echo foobar ; echo baz ; echo blip ; } | tail -n 1\nblip\nshcl\u003e shcl-enable-lisp-syntax\nshcl\u003e if [ ,(+ 1 2 3) = ,(* 2 3) ]; then\n\u003e echo woah wait what\n\u003e fi\nwoah wait what\nshcl\u003e shcl-repl\nshcl (lisp)\u003e (define-builtin upcase ()\n\u003e (loop :for line = (read-line *standard-input* nil :eof)\n\u003e       :until (eq line :eof) :do\n\u003e       (format \"~A~%\" (string-upcase line)))\n\u003e 0)\nUPCASE\nshcl (lisp)\u003e ^D\nshcl\u003e { echo ahhh ; echo what is going on ; } | upcase\nAHHH\nWHAT IS GOING ON\n#+END_EXAMPLE\n\nOkay, actually, that kind of went off the rails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSquircleSpace%2Fshcl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSquircleSpace%2Fshcl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSquircleSpace%2Fshcl/lists"}