Re: /usr/bin/django-admin in python-django
Hi,
Karsten Hilbert:
> Writing '''' would make the first quote escape the second.
>
Not escape, but …
> Or some such :-)
>
To make this more explicit:
foo=''' '
echo This is Shell code
exec python $0
' '''
print("This is Python")
So to Python, you have a (multiline, hence the triple-quote) string which
contains of a space and a single quote, a linefeed, random text, and the
reverse linefeed-singlequote-space combo.
To the shell, $foo is a single space.
In fact, I would do this slightly differently:
#!/bin/sh
# -*- coding: utf-8 -*-
shell_code=''' '
echo This is Shell
exec python $0
python_code='''
## ONLY use DOUBLE quotes ‹"› after this line
print("This is Python")
# End of Python code. Do not modify this line. #'
This way, "dash -n $SCRIPT" will ignore the Python code
(since it's a string) and not report a syntax error.
--
-- Matthias Urlichs
Reply to: