URL: https://linuxfr.org/users/chat_de_sorciere/journaux/rashell-une-bibliotheque-pour-remplacer-les-scripts-shells-par-du-lisp Title: Rashell – Une bibliothèque pour remplacer les scripts shells par du Lisp Authors: Michaël Date: 2020年10月11日T17:54:29+02:00 License: CC By-SA Tags: lisp et shell Score: 8 **Rashell** est une bibliothèque Common Lisp pour écrire des remplacements robustes et propices à la maintenance aux scripts shell. **Rashell** identifie quelques façons typiques d'interagir avec les programmes externes: - les *utilities* qu'on utilise comme **cp**, **rm**, **mv**; - les *tests* qu'on utilise comme des prédicats, notamment **test** ou parfois **grep**. - les *queries* qu'on utilise pour produire une liste de résultats, comme **find** ou **grep** par exemple. - les *filters* qu'on applique sur un fichier, une séquence de lignes, une *string*, etc; par exemple **sed** et **awk**. Voici des exemples de **Rashell** en action: ~~~ lisp RASHELL> (run-utility (cp #p"LICENSE" #p"LICENSE.bak")) "" "" RASHELL> (describe (cp #p"LICENSE" #p"LICENSE.bak")) # [standard-object] A command to run the program #P"/bin/cp" on the arguments ("LICENSE" "LICENSE.bak"). Status: The command has not been started yet. RASHELL> (run-query (find* '(:and (:has-kind :regular)(:name "*.lisp")) #p"src")) ("src/package.lisp" "src/posix.lisp" "src/util.lisp" "src/rashell.lisp") RASHELL> (do-query (regular-file (find* '(:and (:has-kind :regular)(:name "*.lisp")) #p"src")) (format t "~&Regular file ~A" regular-file)) Regular file src/package.lisp Regular file src/posix.lisp Regular file src/util.lisp Regular file src/rashell.lisp NIL RASHELL> (run-query (df #p".")) (#S(FREE-DISK-SPACE :DEVICE "/dev/disk1s6" :BLOCKS 976797816 :USED 255096096 :FREE 489110320 :CAPACITY 35.0 :MOUNTED-ON "/System/Volumes/Data")) RASHELL> (run-filter (sed "/TODO:/p" :echo t) "(define-command sed (...) # TODO: Prepare SED-program language DSL instead of using a string SED-program. ...") "# TODO: Prepare SED-program language DSL instead of using a string SED-program." ~~~ Pour l'instant **Rashell** est seulement compatible avec SBCL. - [Doc PDF](https://michipili.github.io/assets/cl-rashell/rashell.pdf) - [Repo GitHub](https://github.com/michipili/cl-rashell) - [Annonce Reddit](https://www.reddit.com/r/lisp/comments/j94k4c/rashell_resilient_replicant_shell_programming/)

AltStyle によって変換されたページ (->オリジナル) /