From a5cca6de7582372545c6af742cd5e1f41eb28369 Mon Sep 17 00:00:00 2001 From: Aron Griffis <aron@arongriffis.com> Date: Mon, 17 Feb 2014 14:49:09 -0500 Subject: [PATCH] Use a sed() function for unbuffered output. In `bin/steps/collectstatic` the unbuffered output in `indent` is subverted by calling `sed` first: ```shell python $MANAGE_FILE collectstatic --noinput 2>&1 | sed '/^Copying/d;/^$/d;/^ /d' | indent ``` This commit fixes this by making `sed` itself unbuffered rather than putting that logic in the `indent` function. --- bin/steps/collectstatic | 6 +----- bin/utils | 13 ++++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bin/steps/collectstatic b/bin/steps/collectstatic index bd357326..ad6fdca2 100755 --- a/bin/steps/collectstatic +++ b/bin/steps/collectstatic @@ -1,10 +1,6 @@ #!/usr/bin/env bash -# Syntax sugar. -indent() { - RE="s/^/ /" - [ $(uname) == "Darwin" ] && sed -l "$RE" || sed -u "$RE" -} +source $BIN_DIR/utils MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' | head -1) MANAGE_FILE=${MANAGE_FILE:-fakepath} diff --git a/bin/utils b/bin/utils index a8af9fbf..9f6ecb03 100755 --- a/bin/utils +++ b/bin/utils @@ -1,16 +1,19 @@ shopt -s extglob -[ $(uname) == "Darwin" ] && SED_FLAG='-l' || SED_FLAG='-u' +if [ $(uname) == Darwin ]; then + sed() { command sed -l "$@"; } +else + sed() { command sed -u "$@"; } +fi # Syntax sugar. indent() { - RE="s/^/ /" - sed $SED_FLAG "$RE" + sed "s/^/ /" } # Clean up pip output cleanup() { - sed $SED_FLAG -e 's/\.\.\.\+/.../g' | sed $SED_FLAG '/already satisfied/Id' | sed $SED_FLAG -e '/Overwriting/Id' | sed $SED_FLAG -e '/python executable/Id' | sed $SED_FLAG -e '/no previously-included files/Id' + sed -e 's/\.\.\.\+/.../g' | sed -e '/already satisfied/Id' | sed -e '/Overwriting/Id' | sed -e '/python executable/Id' | sed -e '/no previously-included files/Id' } # Buildpack Steps. @@ -77,4 +80,4 @@ sub-env() { $1 ) -} \ No newline at end of file +} -- GitLab