Skip to content

Instantly share code, notes, and snippets.

@dougpagani
Last active January 19, 2019 21:03
Show Gist options
  • Save dougpagani/510ba583279da260513939fb0aa037b6 to your computer and use it in GitHub Desktop.
Save dougpagani/510ba583279da260513939fb0aa037b6 to your computer and use it in GitHub Desktop.
Quick Cheatsheets when debugging bash command line construction
# https://bashrules.blogspot.com/2006/04/bash-order-of-expansions.html
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html
alias bashexpandorder='echo '\''
1. {} brace
2. ~ tilde
3. $VAR parameter & variable
4. $() command-substitution
5. $(()) arithmetic expansion
6. (IFS) word-splitting
7. * ? [ filename expansion (-f will disable)
X. quote-removal
...
?. proces substitusion
?. word-splitting
'\'''
alias bashparsinglevels=bashexpandorder
# https://unix.stackexchange.com/a/60889
# http://mywiki.wooledge.org/BashParser
alias bashactionorder="echo '
1. READ DATA to execute
2. Process QUOTES
'\'' :
\" : \ $ \`\`
3. SPLIT the read data into COMMANDS
4. Parse SPECIAL OPERATORS
5. Perform EXPANSIONS
6. Split the command into a COMMAND NAME AND ARGUMENTS
7. EXECUTE the command
'"
# More comprehensive resource: (the actual
# http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment