Merge pull request #1238 from devnsec-com/pr5

Use `printf` instead of `echo -n` for better portability
This commit is contained in:
bmw 2015-10-30 17:04:12 -07:00
commit c39bc12b18
3 changed files with 11 additions and 12 deletions

View file

@ -25,9 +25,9 @@ pip install -U letsencrypt letsencrypt-apache # letsencrypt-nginx
echo
echo "Congratulations, Let's Encrypt has been successfully installed/updated!"
echo
echo -n "Your prompt should now be prepended with ($VENV_NAME). Next "
echo -n "time, if the prompt is different, 'source' this script again "
echo -n "before running 'letsencrypt'."
printf "%s" "Your prompt should now be prepended with ($VENV_NAME). Next "
printf "time, if the prompt is different, 'source' this script again "
printf "before running 'letsencrypt'."
echo
echo
echo "You can now run 'letsencrypt --help'."

View file

@ -73,7 +73,7 @@ then
fi
fi
echo -n "Updating letsencrypt and virtual environment dependencies..."
printf "Updating letsencrypt and virtual environment dependencies..."
if [ "$VERBOSE" = 1 ] ; then
echo
$VENV_BIN/pip install -U setuptools
@ -86,15 +86,15 @@ if [ "$VERBOSE" = 1 ] ; then
fi
else
$VENV_BIN/pip install -U setuptools > /dev/null
echo -n .
printf .
$VENV_BIN/pip install -U pip > /dev/null
echo -n .
printf .
# nginx is buggy / disabled for now...
$VENV_BIN/pip install -U letsencrypt > /dev/null
echo -n .
printf .
$VENV_BIN/pip install -U letsencrypt-apache > /dev/null
if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
echo -n .
printf .
$VENV_BIN/pip install -U letsencrypt-nginx > /dev/null
fi
echo

View file

@ -70,7 +70,7 @@ Are you OK with your IP being logged?
CMD_TEMPLATE = """\
mkdir -p {root}/public_html/{response.URI_ROOT_PATH}
cd {root}/public_html
echo -n {validation} > {response.URI_ROOT_PATH}/{encoded_token}
printf "%s" {validation} > {response.URI_ROOT_PATH}/{encoded_token}
# run only once per server:
$(command -v python2 || command -v python2.7 || command -v python2.6) -c \\
"import BaseHTTPServer, SimpleHTTPServer; \\
@ -142,15 +142,14 @@ s.serve_forever()" """
ct=response.CONTENT_TYPE, port=port)
if self.conf("test-mode"):
logger.debug("Test mode. Executing the manual command: %s", command)
# sh shipped with OS X does't support echo -n
executable = "/bin/bash" if sys.platform == "darwin" else None
# sh shipped with OS X does't support echo -n, but supports printf
try:
self._httpd = subprocess.Popen(
command,
# don't care about setting stdout and stderr,
# we're in test mode anyway
shell=True,
executable=executable,
executable=None,
# "preexec_fn" is UNIX specific, but so is "command"
preexec_fn=os.setsid)
except OSError as error: # ValueError should not happen!