Sha256: e451291b40bbc495aabef4e0be9d51be006b1d4b52dc53677b27f2a25d9f4269

Contents?: true

Size: 645 Bytes

Versions: 17

Compression:

Stored size: 645 Bytes

Contents

#!/usr/bin/bash

# NAME
#   strip-comments - Remove comments from postgres files
#
# USAGE
#   strip-comments [FILE]
#
# DESCRIPTION
#   Remove comments and blank lines from standard intput or the given file and
#   write the result on standard output
#
# REFERENCES
#   https://stackoverflow.com/a/35708616/1745001
#

PROGRAM=$(basename $0)
USAGE="[FILE]"

function error() {
    echo "$PROGRAM: $@"
    echo "Usage: $PROGRAM $USAGE"
    exit 1
} >&2

[ $# -le 1 ] || error "Illegal number of arguments"
FILE=$1

sed '/^\s*--/d' $FILE \
|   sed 's/a/aA/g; s/__/aB/g; s/#/aC/g' \
|   gcc -P -E -ansi - \
|   sed 's/aC/#/g; s/aB/__/g; s/aA/a/g'

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
prick-0.19.0 libexec/strip-comments
prick-0.18.0 libexec/strip-comments
prick-0.17.0 libexec/strip-comments
prick-0.16.0 libexec/strip-comments
prick-0.15.0 libexec/strip-comments
prick-0.14.0 libexec/strip-comments
prick-0.13.0 libexec/strip-comments
prick-0.12.0 libexec/strip-comments
prick-0.11.0 libexec/strip-comments
prick-0.10.0 libexec/strip-comments
prick-0.9.0 libexec/strip-comments
prick-0.8.0 libexec/strip-comments
prick-0.7.0 libexec/strip-comments
prick-0.6.0 libexec/strip-comments
prick-0.5.0 libexec/strip-comments
prick-0.4.0 libexec/strip-comments
prick-0.3.0 libexec/strip-comments