4 ms·
I always wanted a shell best practices book (for formatting, beyond the TLDP Advanced Bash Guide, or dare I even say the POSIX spec). I will definitely checkou
by 616c 13y ago
I always wanted a shell best practices book (for formatting, beyond the TLDP Advanced Bash Guide, or dare I even say the POSIX spec). I will definitely checkout the Gentoo ebuild scripts. I used to look at Debian in my youth to try and find someone to imitate.
However, are there are any people writing lint or prettify or Perl Critic like progs or web services that will properly wrap and do things you mention?
Would there be interest in such a thing?
UPDATE: I found this stuff. Does anyone use these things?
https://trac.id.ethz.ch/projects/bashcritic/ https://trac.id.ethz.ch/projects/bashcritic/
http://man.he.net/man1/checkbashisms http://man.he.net/man1/checkbashisms
http://stackoverflow.com/questions/3668665/is-there-a-static-analysis-tool-like-lint-or-perlcritic-for-shell-scripts http://stackoverflow.com/questions/3668665/is-there-a-static...
- 616c 13y agoAlso found very cool meet me in the middle type projects, where you can interact with Shell in different programming languages, or "transpile" to it like CoffeeScript -> Javascript. The most interesting so far: Sh.py [0] (mentioned here before [1]) and plumbum [2], which is surprisingly extensive. [0] http://amoffat.github.io/sh/ http://amoffat.github.io/sh/ [1] http://news.ycombinator.com/item?id=4531645 http://news.ycombinator.com/item?id=4531645 [2] https://github.com/tomerfiliba/plumbum https://github.com/tomerfiliba/plumbum
- dmckeon 13y agoA (cheap) trick for formatting shell scripts is approximately: wrap script into a shell function source function definition diff defined function against script with something like: { printf 'dummy (){ ' cat script printf "; };\ntype -a dummy\n" } > dummy source dummy > defined rm dummy; unset -f dummy diff script defined Issues include: comments are absent from defined function listing trailing semicolons appear after each shell command / line the first semi in the trailing "; };" may be a syntax error The default function listing format is fairly generic, so personal formatting preferences must be left as an exercise for the reader. MHO: people who insist on specific code formats should provide tools that can convert arbitrary code into their preferred format.