File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed
Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change 1- #! /usr/bin/env bash
2- set -o errexit -o errtrace -o noclobber -o nounset -o pipefail
3- IFS=$' \n\t '
1+ #! /usr/bin/env sh
42
5- script_dir=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
3+ script_dir=$( cd " $( dirname " $0 " ) " && pwd)
64
7- function usage() {
5+ usage () {
86 if [ -n " ${1:- } " ]; then
97 >&2 cat << EOF
108$1
1311 fi
1412
1513 >&2 cat << EOF
16- Usage: ${BASH_SOURCE[0]} site-uri
14+ Usage: $0 site-uri
1715
1816EOF
1917 exit 1
2018}
2119
22- if (( $# < 1 )) ; then
23- usage " Too few arguments"
24- fi
25-
2620site_uri=" $1 "
2721
2822if [ -z " $site_uri " ]; then
29- usage " Invalid site-uri"
23+ usage " Missing site-uri"
3024fi
3125
3226# cd "$project_dir"
3327
34- filenames=( " $script_dir " /export_* .sql)
28+ filenames=" $script_dir /export_*.sql"
3529
36- for filename in " ${ filenames[@]} " ; do
30+ for filename in $ filenames; do
3731 echo " Running $filename "
3832
3933 # JSON
4034
4135 # https://tldp.org/LDP/abs/html/string-manipulation.html
42- output_filename=${ filename/% .sql / . json}
36+ output_filename=" $ filename. json"
4337 # https://github.com/drush-ops/drush/issues/3071#issuecomment-347929777
4438 vendor/bin/drush --uri=" $site_uri " php:eval " return \Drupal::database()->query(file_get_contents('$filename '))->fetchAll()" --format=json > | " $output_filename " || true
4539 ls -lh " $output_filename "
4640
4741 # CSV
4842
49- output_filename=${ filename/% .sql / . csv}
43+ output_filename=" $ filename. csv"
5044 # https://stackoverflow.com/a/22421445/2502647
5145 vendor/bin/drush --uri=" $site_uri " sql:cli < " $filename " | awk ' BEGIN { FS="\t"; OFS="," } {
5246 rebuilt=0
You can’t perform that action at this time.
0 commit comments