Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Adding arbitrary data at the end of a script



    Hi all :)

    I'm doing a self-contained script that needs some data to work.
This data is going to be added at the end of script (after the 'exit
0' command that terminates the script), but zsh reads *and tries to
expand* the entire bunch of data. I haven't found in SUS anything
that forbids or allows this behaviour, and I'm confused.

    The script is functionally like this:

#!/bin/zsh
true
exit 0
<Text data that contains some '$', backticks, etc.>

    I've tried this, too:

#!/bin/zsh
true
exit 0
cat << DATA.EOF > /dev/null
<Text data that contains some '$', backticks, etc.>
DATA.EOF

    Obviously, I can quote, by hand, all things that makes the shell
barf (not only Zsh, Bash suffer from this too), but I would like to
avoid it because it will be very time consuming and error prone. In
fact, the 'bunch of data' is no more than a shell script skeleton
that will be processed through sed. The main script uses something
like this:

cat 0 | sed...

    to process itself and the bunch of data and generate another
script.

    If I cannot avoid the data to be read by the shell, how can I
avoid expansion portably? The script must be self-contained, and the
data must go inside of it. I've thought of a solution but it's not
very good for me and I would like to avoid it: ASCII armoring the
'data' (removing the shell metachars in the process) and dearmoring
it on the fly while processing through sed...

    Thanks in advance :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...



Messages sorted by: Reverse Date, Date, Thread, Author