I create bash scripts which get sourced from another main script to set up variables needed by the main script. These variables need to be able to contain any character and not have them interpreted by the shell. For example:a single quote: 'dollar sign: $asterix: *pound sign: #, etc.So, my thinking was to use a single quote and escape any enclosed single quotes and # characters. But, am getting a unexpected EOF while looking for matching error with the two files below.Question:What is the best way to define a string which can contain any set of characters that would require the least amount of tweaking? There are thousands of such foo.sh files and as the string is being extracted form another source, I want to minimize the number of special characters that I need to escape.What other characters do I need to escape.The desired output form the following scripts below is\MyMacro{*,Baker's Dozen,$x^$,#}Platform:MacOS 10.9.5Sub Shell: foo.shset -fstring_list='*,Baker\'s Dozen,$x^$,\#'set +fMain Shell: main.shsource foo.shprintf %s{%s} \MyMacro ${string_list}
Define string with the characters *, single quote and $
bash;shell;shell script;quoting;special characters