[TynesideLUG] bash musings - have I overlooked something?
Ian Bruntlett
ian.bruntlett at gmail.com
Mon Jun 28 11:55:46 UTC 2021
Hi,
I've created a spreadsheet to gather together what happens when these
things happen:
* Variable (e.g. $BASH_VERSION) interpolation Always occurred except when
single quoted
* Positional parameters (r..g. $1) Always occurred except when single quoted
* backslashed escaped characters (e.g. \t) Always occurred except when NO
quotes
Here are the shell scripts I used to come to those conclusions...
#!/bin/bash
echo hellos - Demonstrating where backslashed escaped characters are done.
echo -e "No quotes " Hello\tWorld
echo -e "Single quotes " 'Hello\tWorld'
echo -e "Double quotes " 'Hello\tWorld'
#!/bin/bash
echo pos_params - show positional parameter interpolation
echo Param 1 unquoted : $1
echo Param 1 double quoted : "$1"
echo Param 1 single quoted : '$1'
echo Param 10 : ${10}
#!/bin/bash
echo env_vars - show environment variable interpolation
echo "PATH unquoted : " $PATH
echo "PATH double quoted : " "$PATH"
echo "PATH single quoted : " '$PATH'
Have I missed anything out?
TIA,
Ian
--
-- ACCU - Professionalism in programming - http://www.accu.org
-- My writing - https://sites.google.com/site/ianbruntlett/
-- Free Software page -
https://sites.google.com/site/ianbruntlett/home/free-software
More information about the Tyneside
mailing list