dip

old school recipes for janitorial snafu.
git clone git://git.ricketyspace.net/dip.git
Log | Files | Refs

commit 2fe34d61e243f81f3fb116bbec5e6bcd941d1b24
parent 9a09c65e8c662613b75e5f8b7490c23319dba1e8
Author: rsiddharth <s@ricketyspace.net>
Date:   Sun,  6 Jan 2019 09:11:37 -0500

usr: Update pgdump.

* usr/local/bin/pgdump: zsh -> sh

Diffstat:
usr/local/bin/pgdump | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/usr/local/bin/pgdump b/usr/local/bin/pgdump @@ -1,16 +1,16 @@ -#!/usr/bin/env zsh +#!/usr/bin/env sh # # License: CC0-1.0 # # Backup postgres databases. -setopt shwordsplit +set -e dbs_file() { DBS_FILE=$HOME'/.pg-dump-dbs' - if [ ! -r $DBS_FILE ]; then + if ! $(test -r $DBS_FILE); then echo 'Error: ' $DBS_FILE 'not found' exit 1 fi @@ -20,7 +20,7 @@ dbs() { DBS=$(cat $DBS_FILE) - if [ -z "$DBS" ]; then + if $(test -z "$DBS"); then echo 'No databases to dump exiting' exit 0 fi @@ -28,11 +28,11 @@ dbs() init_user() { - if [ ! -z $1 ]; then + if ! $(test -z $1); then USER=$1 fi - if [ -z $USER ]; then + if $(test -z $USER); then echo 'Error: USER not set' exit 1 fi @@ -40,17 +40,17 @@ init_user() init_dumps_dir() { - if [ ! -z $1 ]; then + if ! $(test -z $1); then PGDUMPS_DIR=$1 fi - if [ -z $PGDUMPS_DIR ]; then + if $(test -z $PGDUMPS_DIR); then echo 'Error: PGDUMPS_DIR not set' exit 1 fi # Create dumps directory if not already created. - if [ ! -d $PGDUMPS_DIR ]; then + if ! $(test -d $PGDUMPS_DIR); then echo 'Creating pgdumps directory ' $PGDUMPS_DIR mkdir -p $PGDUMPS_DIR fi @@ -66,10 +66,10 @@ bu_dump_dir() init_dump_dir() { - export DUMP_DIR=$PGDUMPS_DIR'/dump-'$1 + DUMP_DIR=$PGDUMPS_DIR'/dump-'$1 # If it already exists; backup it up. - if [ -d $DUMP_DIR ]; then + if $(test -d $DUMP_DIR); then bu_dump_dir $DUMP_DIR fi }