- https://www.ShellCheck.net/
- https://github.com/koalaman/shellcheck
- “You can cabal, apt, dnf, pkg or brew install it locally right now”
- “already packaged for your distro or package manager”
- “written in Haskell, if you’re into that sort of thing”
Category: The Shell Programming Language
-
“ShellCheck finds bugs in your shell scripts” – shell script analysis tool
-
the “bash” utility has an switch to deal with shell patterns that do not resolve – what’s its name?
$ shopt -s nullglobI am making use of that feature in this script:
-
Unix 7th Edition Manuals in PDF – where to get them
- http://plan9.bell-labs.com/7thEdMan/bswv7.html
- these documents contain the manual pages (in original layout) describing the Bourne Shell, awk etc
-
Bash: [[…]]: the pattern, quoting, …
- https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html — look for the very helpful xxx.txt example!
I was tempted to put the entire pattern in (double) quotes. But that’s not Bash style. You can “certainly” put literal parts in quotes, but regexp parts do not belong in quotes — quotes are good for protecting, amongst other aspects: protecting against interpretation as regular expression. That’s different to usual programming languages. Usually you do sort of put your entire regular expression in “borders” — in Bash you don’t.
This example resp. advice is actually quite wrong (but I am not able to comment there — I have not earned enough reputation on stackoverflow.com yet):
- https://stackoverflow.com/a/13542845/3119172 – the pattern shown there must not be put in quotes
-
ksh88 man page
www2.research.att.com/sw/download/man/man1/ksh88.html – the man page
- NAME
- SYNOPSIS
- DESCRIPTION
- Definitions
- Commands
- Comments
- Aliasing
- Tilde Substitution
- Command Substitution
- Process Substitution
- Parameter Substitution
- Blank Interpretation
- File Name Generation; bash: shopt extglob on # “extended globbing”
- Quoting
- Arithmetic Evaluation
- Prompting
- Conditional Expressions
- Input/Output
- Environment
- Functions
- Jobs
- Signals
- Execution
- Command Re-entry
- In-line Editing Options
- Emacs Editing Mode
- Vi Editing Mode
- Input Edit Commands
- Motion Edit Commands
- Search Edit Commands
- Text Modification Edit Commands
- Other Edit Commands
- Special Commands: …, set, …
- Invocation
- rksh88 Only
- EXIT STATUS
- FILES
- SEE ALSO
- CAVEATS
DESCRIPTION : Functions :… Function identifiers can be listed with the -f or +f option of the typeset special command. … -
O’Reilly Media book: Classic Shell Scripting
- http://shop.oreilly.com/product/9780596005955.do
- https://resources.oreilly.com/examples/9780596005955/ (a Git repository)
- http://examples.oreilly.com/9780596005955/
nice scripts shown there and available in the sample code:
- pathfind.sh – rather similar to my own find_file_on_PATH.sh
- show-identical-files.sh – rather similar to my own group_by_content.sh – but has a problem with “md5sum” – I fixed that
- puser.sh
- …
-
shell programming: “for” loops vs. “while” loops and scope of variables created within loop bodies
Variables, that you create (by assignment) within loop bodies, are well visible outside the loop body. This is valid for both kinds of loop.CAVEAT:If the “while” loop reads from a pipe, the “while” loop is executed within a subshell, i.e. the scope of the variables within the loop ends with the loop.Example:x=a
echo hello |
while read l
do
x=b
done
echo “x=$x”
What’s the output of this echo?x=a
Example:x=a
for l in hello
do
x=b
done
echo “x=$x”What’s the output of this echo?x=b
-
GNU Coreutils “seq”
Why do I keep forgetting the name of this wonderful little helper?
seq prints a sequence of numbers to standard output. Synopses:
seq [option]... last seq [option]... first last seq [option]... first increment lastseq prints the numbers from first to last by increment. By default, each number is printed on a separate line. When increment is not specified, it defaults to ‘1’, even when first is larger than last. first also defaults to ‘1’. So
seq 1prints ‘1’, butseq 0andseq 10 5produce no output. Floating-point numbers may be specified (using a period before any fractional digits).