I have a small Bash script which basically takes a JavaScript file, minifies it using yui-compressor, adds some string and stores it to a different file:
#!/usr/bin/env bash
PATH_OF_SOURCE='../some_directory/some_input_file.js'
PATH_TO_WRITE='some_output_file.js'
CONTENT_VAR=$(yui-compressor ${PATH_OF_SOURCE}) # minify JS file
CONTENT_VAR="{CONTENT_VAR} some_string_here" # Append a string
echo CONTENT_VAR > $PATH_TO_WRITE # Write to file
The problem is: The input JavaScript file contains some stars (*) inside strings like
var myString = 'Fields marked with * are required';
However, my Bash script replaces * with the file list of the current working directory, so I'll get Fields marked with file1.js file2.js ... are required
Of course, I don't want that. And unfortunately, any changing/overwriting of the original input file (like escaping) is out of question: Everything has to happen inside the script.