mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated DevGuide (markdown)
32
DevGuide.md
32
DevGuide.md
@@ -88,20 +88,28 @@ ShellCheck has multiple output formatters. These take parsing results and output
|
||||
|
||||
Let's say that we have a pet peeve: people who use `tmp` as a temporary filename. We want to warn about statements like `sort file > tmp && mv tmp file`, and suggest using `mktemp` instead.
|
||||
|
||||
We can start by looking at the AST for `sort file > tmp`. In a ShellCheck source directory, run `cabal build` to generate necessary files, then run `ghci ShellCheck/Parser.hs`:
|
||||
We can start by looking at the AST for `sort file > tmp`. In a ShellCheck source directory, run `cabal build` to generate necessary files, then run `cabal repl` and `:load src/ShellCheck/Parser.hs`:
|
||||
|
||||
```
|
||||
$ ghci ShellCheck/Parser.hs
|
||||
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
|
||||
Loaded GHCi configuration from /mnt/backup/live/devices/vm-home/haskell/shpell/.ghci
|
||||
[1 of 7] Compiling Paths_ShellCheck ( dist/build/autogen/Paths_ShellCheck.hs, interpreted )
|
||||
[2 of 7] Compiling ShellCheck.Regex ( ShellCheck/Regex.hs, interpreted )
|
||||
[3 of 7] Compiling ShellCheck.AST ( ShellCheck/AST.hs, interpreted )
|
||||
[4 of 7] Compiling ShellCheck.ASTLib ( ShellCheck/ASTLib.hs, interpreted )
|
||||
[5 of 7] Compiling ShellCheck.Interface ( ShellCheck/Interface.hs, interpreted )
|
||||
[6 of 7] Compiling ShellCheck.Data ( ShellCheck/Data.hs, interpreted )
|
||||
[7 of 7] Compiling ShellCheck.Parser ( ShellCheck/Parser.hs, interpreted )
|
||||
Ok, modules loaded: ShellCheck.Parser, ShellCheck.AST, ShellCheck.ASTLib, ShellCheck.Data, ShellCheck.Interface, ShellCheck.Regex, Paths_ShellCheck.
|
||||
$ :load src/ShellCheck/Parser.hs
|
||||
*ShellCheck.AST> :load src/ShellCheck/Parser.hs
|
||||
|
||||
<no location info>: warning: [-Wmissing-home-modules]
|
||||
These modules are needed for compilation but not listed in your .cabal file's other-modules:
|
||||
Paths_ShellCheck
|
||||
ShellCheck.AST
|
||||
ShellCheck.ASTLib
|
||||
ShellCheck.Data
|
||||
ShellCheck.Interface
|
||||
ShellCheck.Regex
|
||||
[1 of 7] Compiling Paths_ShellCheck ( /home/james/repos/shellcheck/dist-newstyle/build/x86_64-linux/ghc-8.8.4/ShellCheck-0.7.2/build/autogen/Paths_ShellCheck.hs, interpreted )
|
||||
[2 of 7] Compiling ShellCheck.Regex ( src/ShellCheck/Regex.hs, interpreted )
|
||||
[3 of 7] Compiling ShellCheck.AST ( src/ShellCheck/AST.hs, interpreted )
|
||||
[4 of 7] Compiling ShellCheck.Interface ( src/ShellCheck/Interface.hs, interpreted )
|
||||
[5 of 7] Compiling ShellCheck.Data ( src/ShellCheck/Data.hs, interpreted )
|
||||
[6 of 7] Compiling ShellCheck.ASTLib ( src/ShellCheck/ASTLib.hs, interpreted )
|
||||
[7 of 7] Compiling ShellCheck.Parser ( src/ShellCheck/Parser.hs, interpreted )
|
||||
Ok, 7 modules loaded.
|
||||
*ShellCheck.Parser>
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user