diff --git a/.asciidoc-pdf-theme.yml b/.asciidoc-pdf-theme.yml index 9586356..23233f0 100644 --- a/.asciidoc-pdf-theme.yml +++ b/.asciidoc-pdf-theme.yml @@ -1,6 +1,94 @@ +extends: default +base: + border-color: 303030 + font: + size: 11 + color: 222222 + family: Barlow + line-height-length: 13 + line-height: $base-line-height-length / $base-font-size +vertical-spacing: $base-line-height-length +code: + background-color: 191919 + font-color: $base-font-color + border-color: 303030 + line-height-length: 12 + line-height: $code-line-height-length / $code-font-size + font: + size: 9 + family: Cascadia +heading: + line-height-length: 20 + line-height: $heading-line-height-length / $heading-font-size + font: + color: BF5F10 + family: Cairo + style: bold + size: 15 +image: + border-radius: 15 +admonition: + column-rule-color: $base-border-color + icon: + caution: + stroke-color: D6A623 + note: + stroke-color: 1040A3 + tip: + stroke-color: 609000 + warning: + stroke-color: E6A623 +link: + font-color: 2353FF +literal: + font-color: 102840 +mark: + background-color: 0030A0 +key: + background-color: F0F0FF + border-color: A0A0A0 +heading: + font-color: $base-font-color +title_page: + title: + font-color: E09000 + authors: + font-color: B06000 +abstract: + font-color: +blockquote: + border-color: $base-border-color + cite: + font-color: 503004 + background-color: 9F7987 +verse: + border-color: $blockquote-border-color + cite: + font-color: $blockquote-cite-font-color +conum: + font-color: $literal-font-color +example: + background-color: $page-background-color + border-color: $base-border-color +sidebar: + background-color: 111111 + border-color: 1A1A1A + title: + font-color: $heading-font-color +thematic-break: + border-color: $base-border-color +table: + background-color: $page-background-color + border-color: 222222 + foot: + background-color: $table-background-color +header: + font-color: 666666 +footer: + border-color: 222222 font: catalog: - merge: true # set value to true to merge catalog with theme you're extending + merge: true set value to true to merge catalog with theme you're extending Barlow: bold: barlowcondensed-semibold.ttf bold_italic: barlowcondensed-semibolditalic.ttf @@ -26,30 +114,14 @@ font: italic: arvo-italic.ttf normal: arvo-regular.ttf Cascadia: - normal: cascadiamono-regular.ttf - bold: cascadiamono-bold.ttf + normal: cascadiamono-light.ttf + bold: cascadiamono-semibold.ttf bold_italic: cascadiamono-semibold.ttf italic: cascadiamono-semilight.ttf -extends: default + semibold: cascadiamono-regular.ttf page: + background-color: FFFFFF layout: portrait margin: [0.75in, 1in, 0.75in, 1in] size: Letter -base: - font: - size: 12 - line-height-length: 15 - line-height: $base-line-height-length / $base-font-size - family: Barlow -code: - font: - size: 9 - line-height-length: 13 - family: Cascadia - line-height: $base-line-height-length / $base-font-size -heading: - font: - family: AdventPro - style: bold -image: - border-radius: 15 + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 201ed02..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: CI -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - tests: - runs-on: ubuntu-latest - services: - postgres: - image: postgres:13.1-alpine - env: - POSTGRES_PASSWORD: password - ports: - - 5432:5432 - # needed because the postgres container does not provide a health check - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - - steps: - - uses: actions/checkout@v2 - - name: Run Regular Test Suite - run: MIN_WIDTH=100 bin/specs -t -c - - uses: ./ - id: cpu-count - - name: Run Tests in Parallel - run: | - export CPU_COUNT="$(cat /proc/cpuinfo | grep processor | wc -l)" - echo "running with CPU_COUNT of ${CPU_COUNT}" - export TERM=xterm-256color - tput setab n; tput clear - export MIN_WIDTH=100 - echo .bats-prefix/bin/bats --pretty -T -j "${CPU_COUNT:-8}" $(find test -name '*_test.bats' -type f) - .bats-prefix/bin/bats --pretty -T -j "${CPU_COUNT:-8}" $(find test -name '*_test.bats' -type f) || true - - shellcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install ShellCheck - run: | - scversion="stable" # or "v0.4.7", or "latest" - wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv - mkdir -p ${HOME}/bin - cp -v "shellcheck-${scversion}/shellcheck" ${HOME}/bin - ${HOME}/bin/shellcheck --version - - name: Run ShellCheck - run: | - ${HOME}/bin/shellcheck -a $(find {bin,lib} -type f) || true - echo; echo; echo - ${HOME}/bin/shellcheck -a $(find {bin,lib} -type f) | egrep -c '^In ' || true - diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..60b44c5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install ShellCheck + run: | + scversion="stable" # or "v0.4.7", or "latest" + wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv + mkdir -p ${HOME}/bin + cp -v "shellcheck-${scversion}/shellcheck" ${HOME}/bin + ${HOME}/bin/shellcheck --version + - name: ShellCheck + run: | + ${HOME}/bin/shellcheck -a $(find {bin,lib} -type f) || true + echo; echo; echo + ${HOME}/bin/shellcheck -a $(find {bin,lib} -type f) | egrep -c '^In ' || true + diff --git a/.github/workflows/parallel.yml b/.github/workflows/parallel.yml new file mode 100644 index 0000000..1536a20 --- /dev/null +++ b/.github/workflows/parallel.yml @@ -0,0 +1,43 @@ +name: Parallel +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + tests: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:13.1-alpine + env: + POSTGRES_PASSWORD: password + ports: + - 5432:5432 + # needed because the postgres container does not provide a health check + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - uses: ./ + id: cpu-count + - name: Run Tests in Parallel + env: + TERM: xterm-256color + MIN_WIDTH: 80 + run: | + export CPU_COUNT="$(cat /proc/cpuinfo | grep processor | wc -l)" + tput setab n; tput clear + source init.sh + output.constrain-screen-width ${MIN_WIDTH} + note "Running specs with CPU_COUNT=${CPU_COUNT}" + h1 ".bats-prefix/bin/bats --pretty -T -j ${CPU_COUNT:-8}" $(find test -name '*_test.bats' -type f) + .bats-prefix/bin/bats --pretty -T -j "${CPU_COUNT:-8}" $(find test -name '*_test.bats' -type f) || { + code=$? + error "Parallel Tests failed with exit code ${code}" + warning "Ignoring parallel test failure...." + } + true + + diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6d96a2d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,27 @@ +name: Test +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + tests: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:13.1-alpine + env: + POSTGRES_PASSWORD: password + ports: + - 5432:5432 + # needed because the postgres container does not provide a health check + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - name: Test + env: + TERM: xterm-256color + MIN_WIDTH: 80 + run: bin/specs -t -c diff --git a/Makefile b/Makefile index 8e6f74d..827d2cf 100755 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # vim: noexpandtab # grep '^[a-z\-]*:' Makefile | cut -d: -f 1 | tr '\n' ' ' -.PHONY: help install fonts-setup fonts-clean update-changelog update-functions update-usage update-readme regenerate-readme reduce-size-readme open-readme git-add update setup test +.PHONY: help install fonts-setup fonts-clean update-changelog update-functions update-usage update-readme regenerate-readme reduce-size-readme open-readme git-add update setup test docker-build docker-run docker-run-bash docker-run-zsh docker-run-fish file-stats-git file-stats-local shell-files red := \033[0;31m bold := \033[1;45m @@ -49,6 +49,29 @@ fonts-setup: fonts-clean: @bash -c 'rm -rf .fonts' + + +file-stats-local: ## Print all non-test files and run `file` utility on them. + @find . -type f \! -ipath '*\.git*' -and ! -ipath '*\.bundle*' -and ! -ipath '*\.bats*' | sed 's/^\.\///g' | xargs file + +shell-files: ## Lists every single checked in SHELL file in this repo + @find . -type f \! -ipath '*\.git*' -and ! -ipath '*\.bundle*' -and ! -ipath '*\.bats*' | sed 's/^\.\///g' | xargs file | grep Bourne | awk '{print $1}' + +make-utf8: ## Convert all text SHELL script files from ASCII to UTF8 format + @bash -c " + function to-utf8() { + FROM_ENCODING="$1" + TO_ENCODING="UTF-8" + CONVERT="iconv -f $FROM_ENCODING -t $TO_ENCODING" + #loop to convert multiple files + for file in *.txt; do + $CONVERT "$file" -o "${file%.txt}.utf8.converted" + done + exit 0 + +file-stats-git: ## Print all files known to `git ls-files` command + @git ls-files | xargs files + update-changelog: ## Auto-generate the doc/CHANGELOG (requires GITHUB_TOKEN env var set) @printf "\n$(bold) ๐Ÿ‘‰ $(red)๎‚ฐ$(clear) $(green)Regenerating CHANGELOG....$(clear)\n" diff --git a/README.adoc b/README.adoc index d47b918..e62f231 100644 --- a/README.adoc +++ b/README.adoc @@ -1,24 +1,30 @@ -:title: Bashmaticโ„ข - BASH primitives for humans and for fun. += icon:terminal[1x, link="https://github.com/kigster/bashmatic"] Bashmaticโ„ข: BASH/ZSH primitives for Humans and for Fun. +:title: Bashmaticโ„ข: BASH/ZSH primitives for Humans and for Fun. +:subtitle: BASH primitives for humans and for fun. :doctype: book :source-highlighter: rouge :rouge-style: base16.monokai :toclevels: 5 :toc: -:sectnums: +:sectnums: 9 :icons: font :license: MIT -= Bashmaticโ„ข - BASH primitives for humans and for fun. +== CI Matrix -image:https://github.com/kigster/bashmatic/workflows/CI/badge.svg[CI Status,link="https://github.com/kigster/bashmatic/actions?query=workflow%3ACI"] -image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic.svg?type=shield[License Status,link=https://app.fossa.com/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic?ref=badge_shield] -image:https://badges.gitter.im/kigster/bashmatic.svg[link="https://gitter.im/kigster/bashmatic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"] +.CI Matrix +[width="80%",cols=">.^s,<.^m,^.^s",frame="topbot",options="header,footer"] +|========================== +| | Badges | FOSSA Scanning +| FOSSSA | image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic.svg?type=shield[License Status,link=https://app.fossa.com/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic?ref=badge_shield] .7+<.>| image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic.svg?type=large[FOSSA License Scan,link=https://app.fossa.com/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic?ref=badge_large] +| CI Tests Parallel | image:https://github.com/kigster/bashmatic/actions/workflows/parallel.yml/badge.svg[Parallel,link=https://github.com/kigster/bashmatic/actions/workflows/parallel.yml] +| CI Tests Serial | image:https://github.com/kigster/bashmatic/actions/workflows/tests.yml/badge.svg[Test,link=https://github.com/kigster/bashmatic/actions/workflows/tests.yml] +| ShellCheck | image:https://github.com/kigster/bashmatic/actions/workflows/lint.yml/badge.svg[Lint,link=https://github.com/kigster/bashmatic/actions/workflows/lint.yml] +| Gitter | image:https://badges.gitter.im/kigster/bashmatic.svg[link="https://gitter.im/kigster/bashmatic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"] +|========================== -image::https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic.svg?type=large[FOSSA License Scan,link=https://app.fossa.com/projects/git%2Bgithub.com%2Fkigster%2Fbashmatic?ref=badge_large] -icon:terminal[5x, link="https://github.com/kigster/bashmatic", window="_blank"] - -## Introduction +== Introduction _Bashmaticยฎ_ is a BASH framework, meaning its a collection of BASH functions (500+ of them) that, we hope, make BASH programming easier, more enjoyable, and more importantly, usable due to the focus on providing constant feedback to the user about what is happening, as a script that uses Bashmatic is running. @@ -189,7 +195,7 @@ $ bashmatic.functions 3 To install Bashmatic manually, follow these steps (feel free to change `BASHMATIC_HOME` if you like): -==== 1. Using Git +=== Using Git [source,bash] ---- @@ -200,7 +206,7 @@ cd "${BASHMATIC_HOME}" && ./bin/bashmatic-install -v cd ->/dev/null ---- -==== 2. Using Curl +=== Using Curl Sometimes you may not be able to use `git` (I have seen issues ranging from local certificate mismatch to old versions of git, and more), but maybe able to download with `curl`. In that case, you can lookup the https://github.com/kigster/bashmatic/tags[latest tag] (substitute "v1.6.0" below with that tag), and then issue this command: @@ -314,13 +320,13 @@ image::doc/img/docker-bash.png[Docker Build,width=80%,align=center] Note how this dropped me straight into the Linux environment prompt with Bashmatic already installed. -== Bashmatic in Action - Practical Examples +== Examples of Bashmatic in Action **Why do we need another BASH framework?** BASH is know to be too verbose and unreliable. We beg to differ. This is why we wanted to start this README with a couple of examples. -=== Example (A): Install Gems via Homebrew +=== Example I. Install Gems via Homebrew Just look at this tiny, five-line script: @@ -349,7 +355,7 @@ Still not convinced? Take a look at a more comprehensive example next. -=== Example (B): Download and install binaries. +=== Example II: Download and install binaries. In this example, we'll download and install binaries `kubectl` and `minikube` binaries into `/usr/local/bin` @@ -374,7 +380,7 @@ NOTE: If you need to create a BASH installer, _Bashmaticยฎ_ offers some incredib Let's get back to the Earth, and talk about how to install Bashmatic, and how to use it in more detail right after. -=== Example ++(C)++: Developer Environment Bootstrap Script +=== Example III: Developer Environment Bootstrap Script This final and most feature-rich example is not just an example โ€“ **it's a working functioning tool that can be used to install a bunch of developer dependencies on your Apple Laptop**. @@ -409,7 +415,7 @@ ${BASHMATIC_HOME}/bin/dev-setup \ This compact command line installs a ton of things, but don't take our word for it - run it yourself. Or, at the very least enjoy this https://github.com/kigster/bashmatic/blob/master/.dev-setup-completed.png[one extremely long screenshot] :) -=== Example (D): Installing GRC Colourify Tool +=== Example IV: Installing GRC Colourify Tool This is a great tool that colorizes nearly any other tool''s output. @@ -423,7 +429,7 @@ You might need to enter your password for SUDO. Once it completes, run `source ~/.bashrc` (or whatever shell you use), and type something like `ls -al` or `netstat -rn` or `ping 1.1.1.1` and notice how all of the above is nicely colored. -=== Example (E): `db` Shortcut for Database Utilities & `db top` +=== Example V: `db` Shortcut for Database Utilities & `db top` If you are using PostgreSQL, you are in luck! Bashmatic includes numerous helpers for PostreSQL's CLI utility `psql`. @@ -495,19 +501,32 @@ image::doc/img/db.png[db usage,border=2,width=80%,align=center] As you might notice, there is an ever-growing list of "actions" โ€” the sub-commands to the `db` script. -==== Commands +=== Sub-Commands of `db` You can view the full list by passing `--commands` flag: image::doc/img/db-commands.png[db usage,border=2,width=80%,align=center] -==== Examples Altgernatively, here is the `--examples` view: image::doc/img/db-examples.png[db examples,border=2,width=80%,align=center] -==== An Example Action โ€” `pg-activity` +==== Sub-Command `db connections` + +You can get a list of all availabled db connections with either + + +[source,bash] +---- +db connections +# OR +db --connections +---- + +image::doc/img/db-connections.png[db usage,border=2,width=80%,align=center] + +==== Sub-Command `db pga` (eg. `pg_activity`) For instance, a recent addition is the ability to invoke https://github.com/dalibo/pg_activity[pg_activity] Python-based DB "top", a much more advanced top query monitor for PostgreSQL. @@ -515,12 +534,35 @@ You can invoke `db pga ` where the connection is taken from the data image::doc/img/db-pga.png[pg_activity,border=2,width=80%,align=center] -==== Connections +==== Other Sub-Commands -You can get a list of all availabled db connections with `db --connections` command: +Once you know what database you are connecting to, you can then run one of the commands: -image::doc/img/db-connections.png[db usage,border=2,width=80%,align=center] +db connect :: +opens psql session to the given connection +db db-settings-toml :: +prints all PostgreSQL settings (obtained with `show all`) as a sorted TOML-formatted file. + +db -q list-tables :: +print a list of all tables in the given database, -q (or --quiet) skips printing the header so that only the table listing is printed. + +db csv :: +export the result of the query as a CSV to STDOUT, eg + +[source,bash] +---- +$ db csv filestore "select * from files limit 2" +---- + +Results in the following output + +[source,CSV] +---- +component_id,file_path,fingerprint_sha_256,fingerprint_comment_stripped_sha_256,license_info +6121f5b3-d68d-479d-9b83-77e9ca07dd2b,weiboSDK/src/main/java/com/sina/weibo/sdk/openapi/models/Tag.java, +6121f5b3-d68d-479d-9b83-77e9ca07dd2b,weiboSDK/src/main/java/com/sina/weibo/sdk/openapi/models/Comment.java, +---- == Usage diff --git a/README.pdf b/README.pdf index 194d6ce..908a3a5 100644 Binary files a/README.pdf and b/README.pdf differ diff --git a/a.adoc b/a.adoc new file mode 100644 index 0000000..70e00a5 --- /dev/null +++ b/a.adoc @@ -0,0 +1,3 @@ +image:https://github.com/kigster/bashmatic/actions/workflows/lint.yml/badge.svg[Lint,link=https://github.com/kigster/bashmatic/actions/workflows/lint.yml] +image:https://github.com/kigster/bashmatic/actions/workflows/parallel.yml/badge.svg[Parallel,link=https://github.com/kigster/bashmatic/actions/workflows/parallel.yml] +image:https://github.com/kigster/bashmatic/actions/workflows/tests.yml/badge.svg[Test,link=https://github.com/kigster/bashmatic/actions/workflows/tests.yml] diff --git a/bin/ascii2utf8 b/bin/ascii2utf8 new file mode 100755 index 0000000..be69f61 --- /dev/null +++ b/bin/ascii2utf8 @@ -0,0 +1,40 @@ +โ—#!/usr/bin/env bash +source ~/.bashmatic/init.sh + +output="${1:-"files-non-utf8-encoded.csv"}" + +printf "%s,%s,%s\n" file_name current_encoding command_to_make_unicode >"${output}" + +#set -eu -o pipefail + +h1 "Detecting encoding of text files in $(pwd -P)..." "Total of $(find . -type f | wc -l | tr -d ' ') files found." + +h2 "Legend:" \ + "๐Ÿฆ„ : ${bldgrn}Already UTF8" " " \ + "๐Ÿ—‘ : ${bldylw}binary file, can't be converted, skipping" " " \ + "๐Ÿฅณ : ${bldpur}ASCII file, can be converted " + +for f in $(find . -type f); do + #file $f | grep -q txt || { + # print "${bldred}โ—" + # continue + #} + + encoding="$(file --mime-encoding $f)" + + [[ ${encoding} == "binary" ]] && { + printf "๐Ÿ—‘ " + continue + } + + [[ ${encoding} == "utf-8" ]] && { + printf "๐Ÿฆ„ " + continue + } + + printf "%s,%s,%s\n" "${file}" "${encoding}" "iconv -f $encoding -t utf-8 $f -o $f" >>${output} + printf "๐Ÿฅณ " + continue +done + +h3 "Please see the results of the scan in the file" "${bldylw}${output}" diff --git a/bin/scheck b/bin/scheck index cb100c9..b288881 100755 --- a/bin/scheck +++ b/bin/scheck @@ -1,35 +1,229 @@ #!/usr/bin/env bash -source ${BASHMATIC_HOME}/init.sh +source "${BASHMATIC_HOME}"/init.sh -set -e -export check_output="/tmp/.bashmatic.${USER}.shcheck" -rm -f ${check_output} && touch ${check_output} +export ROOT=$(pwd -P) +current_dir=${ROOT} +export TEMP_DIR="$(dir.temp)" + +export stdout_output="${TEMP_DIR}/${current_dir}.stdout" +export stderr_output="${TEMP_DIR}/${current_dir}.stderr" + +mkdir -p "$(dirname "${stdout_output}")" || { + abort "Can't create direcory ${stdout_output}" + exit 1 +} + +touch "${stdout_output}" +trap "rm -f ${stdout_output} ${stderr_output}" EXIT set +e -failures=0 +error "fuck" + +export ROOT="${PWD}" +export SHELLCHECK_REPO="https://github.com/koalaman/shellcheck" + +export failures=0 +export sucesses=0 +export flag_patch_mode=0 +declare -a test_files= + +export OKAY="โœ… (checkcheck OK)" +export FAIL="๐Ÿ†˜ (shellcheck failed)" +export NOT_SHELL="๐Ÿฅฅ (not a shell scrip)" +export INVALID="๐Ÿ’ฉ (file or folder is missing)" + run.set-all continue-on-error -h3 "Running shellcheck on all git-committed files that look like shell scripts..." -command -v shellcheck >/dev/null || brew.install.package shellcheck +h2 "ShellCheck Starting in ${PWD}." + +function is.a-shell-file() { + local file="$1" + head -1 "${file}" | + grep -E -q '#\!(/usr/bin/env bash|/bin/bash|/usr/bin/bash|/usr/bin/env zsh|/bin/zsh)' +} + +function is.interactive() { + array.includes "-i" "$@" || \ + array.includes "--interactive" "$@" +} + +function is.patch-mode() { + ((flag_patch_mode)) +} + +function shellcheck-version() { + local file=${1:-"shellcheck"} + printf "v$(shellcheck -V 2>/dev/null | grep version: | sedx 's/^version: //g')" +} + +export LOCAL_SHELLCHECK_VERSION= +if command -v shellcheck >/dev/null; then + export LOCAL_SHELLCHECK_VERSION=$(shellcheck-version) +fi + +function is.shellcheck-current() { + local latest=$(git.repo.latest-remote-tag ${SHELLCHECK_REPO}) + + [[ ${latest} -ne ${LOCAL_SHELLCHECK_VERSION} ]] +} -for file in $(git ls-files); do - [[ -s "${file}" && ! -d "${file}" ]] || continue - head -1 ${file} | grep -E -q '#\!(/usr/bin/env bash|/bin/bash|/usr/bin/bash|/usr/bin/env zsh|/bin/zsh)' || continue - printf "\nโ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”\nFILE: ${file}\n\n" >>${check_output} - run "shellcheck '${file}' >>${check_output}" - code=${LibRun__LastExitCode} - [[ ${code} -ne 0 ]] && failures=$(( failures + 1 )) - [[ ${code} -eq 0 ]] && echo "STATUS: SUCCESS">>${check_output} -done +# โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” +# @description Manually Download and Install ShellCheck +function manual-install() { + local temp="${TEMP_DIR}" + cd "${temp}" >/dev/null + local os=$(uname -s | tr '[:upper:]' '[:lower:]') + curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.${os}.x86_64.tar.xz" -O + is.a-command 7z || package.install p7zip + run "7z x *.xz" + run "7z x *.tar" + arrow.blk-on-ylw "PWD: ${PWD}" + cd "shellcheck-v0.7.1" + + [[ -x /usr/local/bin/shellcheck ]] && run "rm -f /usr/local/bin/shellcheck || sudo rm -f /usr/local/bin/shellcheck || true" + + run "cp -vf shellcheck /usr/local/bin/shellcheck || sudo cp -vf shellcheck /usr/local/bin/shellcheck" + run "chown ${USER} /usr/local/bin/shellcheck || chown ${USER} /usr/local/bin/shellcheck" + run "chmod 755 /usr/local/bin/shellcheck || chmod 755 /usr/local/bin/shellcheck" + + arrow.wht-on-grn "ShellCheck Version is : ${bldylw}$(shellcheck-version)${clr}" + + cd "${ROOT}" || exit 1 + return 0 +} -if [[ ${failures} -eq 0 ]] ; then +function install-shellcheck() { + arrow.blk-on-ylw "Installing ShellCheck..." + if [[ $(command -v shellcheck) != /usr/local/bin/shellcheck ]]; then + is.interactive "$@" && { + run.ui.ask \ + "Replaces your currently installed shellcheck $(shellcheck-version $(command -v shellcheck))" + info "Great, removing it." + } + run "rm -f $(command -v shellcheck)" + run "rm -f /usr/local/bin/shellcheck" + fi + + manual-install && success "ShellCheck Installed $(command -v shellcheck)" "${message}" + sleep 1 && clear + return 0 +} + +function install-manager() { + is.shellcheck-current && install-shellcheck "$@" +} + +function print-report() { + echo + hr + echo + + h3 "Please note that the following shellcheck instructions are being ignored:" \ + "$(cat .shellcheckrc | tr -d '\n')" + + if [[ ${failures} -eq 0 ]]; then success "All files passed shellcheck, congratulations!" - info "NOTE: the following shellcheck instructions are being ignored:" - info "$(cat .shellcheckrc | tr -d '\n')" -else - warning "${failures} files had issues." + else + warning "Discovered ${failures} test issues." info "NOTE: you can find the detailed output of shellcheck in the" - info "following file: ${bldred}${check_output}" - exit 1 -fi + info "following two files: " + info " STDERR: -> ${bldred}${stderr_output}" + info " STDOUT: -> ${bldgrn}${stdout_output}" + fi +} + +function validate-a-file() { + file="$1" + is-dbg && note "Verifying file ${bldylw}${file}" + + [[ ! -s "${file}" || -d "${file}" ]] || { + printf "${INVALID} %s: \n" "${file}" + return + } + + is.a-shell-file "${file}" || { + printf "${NOT_SHELL} %s \n" "${file}" + } + + run "eval \"/usr/local/bin/shellcheck ${flags[*]} ${file}\" >>\"${stdout_output}\" 2>\"${stderr_output}\"" + #eval "/usr/local/bin/shellcheck ${flags[*]} ${file}" >>"${stdout_output}" 2>"${stderr_output}" + code=${code} + if [[ ${code} -ne 0 ]] ; then + failures=$((failures + 1)) + printf "${FAIL} ${bldred}%s ${clr}(Poopmageddon)\n" "${file}" + #printf -- "${OKAY}" + else + successes=$((successes + 1)) + printf "${OKEY}s ${bldgrn}%s ${clr}(Mazel Tov!)\n" "${file}" + fi +} + +function shell-files() { + find {bin,lib} -type f \( -name '*.sh' -or -name '*.bash' -or -name '*' \) -and ! -name '\.*' +} + +# โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” +function execute() { + command -v shellcheck >/dev/null || { + install-manager "$@" + command -v shellcheck >/dev/null && { + error "Cant not find shell check, shoul've been installed." + return 1 + } + } + + local flags + + if [[ -z ${arg[*]} ]]; then + test_files=($(shell-files)) + else + for arg in "$@"; do + if [[ ${arg} =~ \- ]]; then + if [[ ${arg} == "-p" || ${arg} == "--patch" ]]; then + stdout_output="${stdout_output}.patch" + flag_patch_mode=1 + flags="${flags} -F diff "! + fi + else + is.a-shell-file ${arg} && test_files+=( "${arg}" ) + fi + done + fi + + h1 "CLI SCHECK ARGS: ${flags[*]} | FLAGS: ${args[*]} | TOTAL ${#total_files[@]} FILES" + + h3bg STATUS + cursor.up 3 + cursor.right 2 + + for file in "${test_files[@]}"; do + #arrow.wht-on-blu "${file}" + validate-a-file "${file}" + done + + cursor.down 3 + cursor.left -100 +} + + +function main() { + error "FUCK" + install-manager "$@" + + if [[ -n $1 ]]; then + for file in "$@"; do + validate-a-file "${file}" || true + done + else + execute "$@" + fi + + print-report + +} + +bashmatic.detect-subshell || main "$@" + + + diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index a95d3b9..772f791 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [Unreleased](https://github.com/kigster/bashmatic/tree/HEAD) + +[Full Changelog](https://github.com/kigster/bashmatic/compare/v2.0.0...HEAD) + +**Closed issues:** + +- I see "path.mutate" in the commits [\#44](https://github.com/kigster/bashmatic/issues/44) + +**Merged pull requests:** + +- \[Snyk\] Security upgrade ubuntu from latest to groovy-20210325 [\#56](https://github.com/kigster/bashmatic/pull/56) ([snyk-bot](https://github.com/snyk-bot)) +- Config reading, paths mutation tests, db tests, v2.0.0 [\#55](https://github.com/kigster/bashmatic/pull/55) ([kigster](https://github.com/kigster)) +- Adding ability to read from a YAML/JSON configuration file โ€” updating documentation [\#53](https://github.com/kigster/bashmatic/pull/53) ([kigster](https://github.com/kigster)) + +## [v2.0.0](https://github.com/kigster/bashmatic/tree/v2.0.0) (2021-04-03) + +[Full Changelog](https://github.com/kigster/bashmatic/compare/v1.13.0...v2.0.0) + ## [v1.13.0](https://github.com/kigster/bashmatic/tree/v1.13.0) (2021-03-31) [Full Changelog](https://github.com/kigster/bashmatic/compare/v1.11.0...v1.13.0) @@ -71,12 +89,15 @@ - Adding ZSH installation + refactor init.sh [\#32](https://github.com/kigster/bashmatic/pull/32) ([kigster](https://github.com/kigster)) - Synology [\#31](https://github.com/kigster/bashmatic/pull/31) ([kigster](https://github.com/kigster)) - Fixing k8s-example; bin/scheck and a few more [\#30](https://github.com/kigster/bashmatic/pull/30) ([kigster](https://github.com/kigster)) -- Adding `db explain` and --verbose flag. [\#29](https://github.com/kigster/bashmatic/pull/29) ([kigster](https://github.com/kigster)) ## [v1.7.2](https://github.com/kigster/bashmatic/tree/v1.7.2) (2020-12-26) [Full Changelog](https://github.com/kigster/bashmatic/compare/v1.7.1...v1.7.2) +**Merged pull requests:** + +- Adding `db explain` and --verbose flag. [\#29](https://github.com/kigster/bashmatic/pull/29) ([kigster](https://github.com/kigster)) + ## [v1.7.1](https://github.com/kigster/bashmatic/tree/v1.7.1) (2020-12-22) [Full Changelog](https://github.com/kigster/bashmatic/compare/v1.7.0...v1.7.1) @@ -135,15 +156,18 @@ **Merged pull requests:** - Adding array.sort, array.uniq and array.sort-numeric [\#14](https://github.com/kigster/bashmatic/pull/14) ([kigster](https://github.com/kigster)) -- Adding documentation for dbtop + PDF generator [\#13](https://github.com/kigster/bashmatic/pull/13) ([kigster](https://github.com/kigster)) -- Fixing dbtop [\#11](https://github.com/kigster/bashmatic/pull/11) ([kigster](https://github.com/kigster)) -- Add license scan report and status [\#10](https://github.com/kigster/bashmatic/pull/10) ([fossabot](https://github.com/fossabot)) -- Adding bin/pdf-reduce and other tweaks [\#9](https://github.com/kigster/bashmatic/pull/9) ([kigster](https://github.com/kigster)) ## [v1.3.0](https://github.com/kigster/bashmatic/tree/v1.3.0) (2020-09-22) [Full Changelog](https://github.com/kigster/bashmatic/compare/v1.2.1...v1.3.0) +**Merged pull requests:** + +- Adding documentation for dbtop + PDF generator [\#13](https://github.com/kigster/bashmatic/pull/13) ([kigster](https://github.com/kigster)) +- Fixing dbtop [\#11](https://github.com/kigster/bashmatic/pull/11) ([kigster](https://github.com/kigster)) +- Add license scan report and status [\#10](https://github.com/kigster/bashmatic/pull/10) ([fossabot](https://github.com/fossabot)) +- Adding bin/pdf-reduce and other tweaks [\#9](https://github.com/kigster/bashmatic/pull/9) ([kigster](https://github.com/kigster)) + ## [v1.2.1](https://github.com/kigster/bashmatic/tree/v1.2.1) (2020-06-26) [Full Changelog](https://github.com/kigster/bashmatic/compare/v1.2.0...v1.2.1) @@ -171,14 +195,17 @@ **Merged pull requests:** - Kig/cherry pick bashmatic setup [\#6](https://github.com/kigster/bashmatic/pull/6) ([kigster](https://github.com/kigster)) -- Minor revision to the runtime UI [\#4](https://github.com/kigster/bashmatic/pull/4) ([kigster](https://github.com/kigster)) -- \[feature\] Introducing new runtime option show-command-on/off [\#3](https://github.com/kigster/bashmatic/pull/3) ([kigster](https://github.com/kigster)) -- Kig/gem related fixes and installer [\#2](https://github.com/kigster/bashmatic/pull/2) ([kigster](https://github.com/kigster)) ## [v0.2.0](https://github.com/kigster/bashmatic/tree/v0.2.0) (2019-12-24) [Full Changelog](https://github.com/kigster/bashmatic/compare/875b23408925e8908fc1f23f5f0c1470fe43dc03...v0.2.0) +**Merged pull requests:** + +- Minor revision to the runtime UI [\#4](https://github.com/kigster/bashmatic/pull/4) ([kigster](https://github.com/kigster)) +- \[feature\] Introducing new runtime option show-command-on/off [\#3](https://github.com/kigster/bashmatic/pull/3) ([kigster](https://github.com/kigster)) +- Kig/gem related fixes and installer [\#2](https://github.com/kigster/bashmatic/pull/2) ([kigster](https://github.com/kigster)) + \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/doc/FUNCTIONS.adoc b/doc/FUNCTIONS.adoc index 9014613..701c9b6 100644 --- a/doc/FUNCTIONS.adoc +++ b/doc/FUNCTIONS.adoc @@ -2002,8 +2002,11 @@ db.actions.connections () ---- db.actions.csv () { + local dbname=${1} + shift + [[ -z ${dbname} ]] && return 1 export flag_quiet=1 - db.psql.run "$@" --csv -A -P pager=off -P footer=off + db.psql.connect "${dbname}" -P border=0 -P fieldsep="," --csv -A -X -P pager=off -P footer=off -c "\"$@\"" } ---- @@ -2432,7 +2435,7 @@ db.psql.connect () ---- db.psql.connect.db-settings-pretty () { - db.psql.connect "$@" -A -X -q -c 'show all' | grep -v 'rows)' | sort | awk "BEGIN{FS=\"|\"}{ printf(\"%-40.40s %-30.30s ## %s\n\", \$1, \$2, \$3) }" | sedx '/##\s*$/d' | GREP_COLOR="1;32" grep -E -C 1000 -i --color=always -e '^([^ ]*)' | GREP_COLOR="3;0;34" grep -E -C 1000 -i --color=always -e '##.*$|$' + db.psql.connect "$@" -A -X -q -c "\"show all\"" | grep -v 'rows)' | sort | awk "BEGIN{FS=\"|\"}{ printf(\"%-40.40s %-30.30s ## %s\n\", \$1, \$2, \$3) }" | sedx '/##\s*$/d' | GREP_COLOR="1;32" grep -E -C 1000 -i --color=always -e '^([^ ]*)' | GREP_COLOR="3;0;34" grep -E -C 1000 -i --color=always -e '##.*$|$' } ---- @@ -2443,7 +2446,7 @@ db.psql.connect.db-settings-pretty () ---- db.psql.connect.db-settings-toml () { - db.psql.connect.just-data "$1" -c 'show all' | awk 'BEGIN{FS="|"}{printf "%s=%s\n", $1, $2}' | sort + db.psql.connect.just-data "$1" -c "\"show all\"" | awk 'BEGIN{FS="|"}{printf "%s=%s\n", $1, $2}' | sort } ---- @@ -2506,7 +2509,7 @@ db.psql.connect.table-settings-show () ---- db.psql.db-settings () { - psql "$*" -X -q -c 'show all' | sort | awk '{ printf("%s=%s\n", $1, $3) }' | sed -E 's/[()\-]//g;/name=setting/d;/^[-+=]*$/d;/^[0-9]*=$/d' + psql "$*" -X -q -c "\"show all\"" | sort | awk '{ printf("%s=%s\n", $1, $3) }' | sed -E 's/[()\-]//g;/name=setting/d;/^[-+=]*$/d;/^[0-9]*=$/d' } ---- @@ -2576,7 +2579,7 @@ db.psql.run () { local dbname="$1" shift - db.psql.connect "${dbname}" -X --pset border=0 -c "$@" + db.psql.connect "${dbname}" -X --pset border=0 -c "\"$@\"" } ---- @@ -3370,6 +3373,26 @@ dir.find () ---- +==== `dir.temp` + +[source,bash] +---- +dir.temp () +{ + local dir="$(file.temp)/$$/${RANDOM/284/_-=}" + mkdir -p "${dir}" 2> /dev/null + [[ -n $DEBUG ]] && { + info "temporary folder is: ${dir}" + inf "it exists? " + [[ -d ${dir} ]] && ok: + [[ -d ${dir} ]] || not-ok: + } + printf "%s" "${dir}" + trap "rm -rf ${dir}" EXIT +} + +---- + ==== `file.ask.if-exists` [source,bash] @@ -3673,7 +3696,7 @@ file.temp () { local host="${HOST:-${HOSTNAME:-$(hostname)}}" local user="${USER:-"$(whoami)"}" - local temp_file_pattern=".bashmatic.${host}.${user}." + local temp_file_pattern=".bashmatic.${host}.${user}.${*/ /}" local n="$(epoch)" local t=$((n % 99991)) local file="/tmp/${temp_file_pattern}${n}$$${t}${RANDOM}${RANDOM}" @@ -4434,6 +4457,18 @@ git.repo-is-clean () ---- +==== `git.repo.latest-remote-tag` + +[source,bash] +---- +git.repo.latest-remote-tag () +{ + local repo_url="$1" + git ls-remote --tags --sort="v:refname" ${repo_url} | grep -E \-v '(latest|stable)' | grep -E -v '\^{}' | tail -1 | awk 'BEGIN{FS="/"}{print $3}' +} + +---- + ==== `git.repo.remote-to-git@` [source,bash] diff --git a/doc/USAGE.md b/doc/USAGE.md index 7cd6c34..deb2be9 100644 --- a/doc/USAGE.md +++ b/doc/USAGE.md @@ -989,6 +989,21 @@ Regenerates USAGE.adoc && USAGE.pdf shrinkgs PDF + + +--- + + +## File `bin/scheck` + + + +* [manual-install()](#manual-install) + +### `manual-install()` + +Manually Download and Install ShellCheck + ## Copyright & License * Copyright ยฉ 2017-2021 Konstantin Gredeskoul, All rights reserved. diff --git a/doc/USAGE.pdf b/doc/USAGE.pdf index 8fb7f3a..358ab7a 100644 Binary files a/doc/USAGE.pdf and b/doc/USAGE.pdf differ diff --git a/lib/db.sh b/lib/db.sh index f5a989a..d67bc1d 100644 --- a/lib/db.sh +++ b/lib/db.sh @@ -189,7 +189,7 @@ db.psql.connect.just-data() { db.psql.run() { local dbname="$1"; shift - db.psql.connect "${dbname}" -X --pset border=0 -c "$@" + db.psql.connect "${dbname}" -X --pset border=0 -c "\"$@\"" } db.psql.list-users() { @@ -350,8 +350,10 @@ db.actions.run() { } db.actions.csv() { + local dbname=${1}; shift + [[ -z ${dbname} ]] && return 1 export flag_quiet=1 - db.psql.run "$@" --csv -A -P pager=off -P footer=off + db.psql.connect "${dbname}" -P border=0 -P fieldsep="," --csv -A -X -P pager=off -P footer=off -c "\"$@\"" } db.actions.explain() { diff --git a/lib/file.sh b/lib/file.sh index c36740f..920b3eb 100644 --- a/lib/file.sh +++ b/lib/file.sh @@ -5,7 +5,7 @@ export bashmatic__temp_file_pattern=".bashmatic.${bashmatic__hostname}.${USER}." function file.temp() { local host="${HOST:-${HOSTNAME:-$(hostname)}}" local user="${USER:-"$(whoami)"}" - local temp_file_pattern=".bashmatic.${host}.${user}." + local temp_file_pattern=".bashmatic.${host}.${user}.${*/ /}" local n="$(epoch)" local t=$((n % 99991)) local file="/tmp/${temp_file_pattern}${n}$$${t}${RANDOM}${RANDOM}" @@ -18,6 +18,19 @@ function file.temp() { echo "${file}" } +function dir.temp() { + local dir="$(file.temp)/$$/${RANDOM/284/_-=}" + mkdir -p "${dir}" 2>/dev/null + [[ -n $DEBUG ]] && { + info "temporary folder is: ${dir}" + inf "it exists? " + [[ -d ${dir} ]] && ok: + [[ -d ${dir} ]] || not-ok: + } + printf "%s" "${dir}" + trap "rm -rf ${dir}" EXIT +} + # Makes a file executable but only if it already contains # a "bang" line at the top. # diff --git a/lib/git.sh b/lib/git.sh index 2ce8a53..4ff5b17 100644 --- a/lib/git.sh +++ b/lib/git.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash # @brief Functions in this file manage git repos, including this one. +function git.repo.latest-remote-tag() { + local repo_url="$1" + git ls-remote --tags --sort="v:refname" ${repo_url} | grep -E \-v '(latest|stable)' | grep -E -v '\^{}'| tail -1 | awk 'BEGIN{FS="/"}{print $3}' +} + function git.configure-auto-updates() { export LibGit__StaleAfterThisManyHours="${LibGit__StaleAfterThisManyHours:-"1"}" export LibGit__LastUpdateTimestampFile="${BASHMATIC_TEMP}/.config/$(echo ${USER} | shasum.sha-only-stdin)" diff --git a/test/dir_test.bats b/test/dir_test.bats index 4b295d6..fd77dc0 100644 --- a/test/dir_test.bats +++ b/test/dir_test.bats @@ -2,13 +2,19 @@ load test_helper source lib/dir.sh +source lib/file.sh export HOME_DIR=${HOME/\/$(whoami)/} set -e +setup() { + export TEMP_DIR=$(file.temp -d) +} + @test "dir.short-home ${HOME}/workspace/project" { export HOME + export local dir="$(dir.short-home "${HOME}/workspace/project")" echo "${dir}" > /tmp/a [[ "${dir}" == '~/workspace/project' ]] diff --git a/test/helpers/test-lib.sh b/test/helpers/test-lib.sh index 0279041..40bc3b2 100755 --- a/test/helpers/test-lib.sh +++ b/test/helpers/test-lib.sh @@ -11,28 +11,30 @@ readonly BATS_SOURCES_CORE="https://github.com/bats-core/bats-core.git" # readonly BATS_SOURCES_SUPPORT="https://github.com/bats-core/bats-support" -export DEFALT_MIN_WIDTH=92 +export DEFALT_MIN_WIDTH=80 export UI_WIDTH=${UI_WIDTH:-${DEFALT_MIN_WIDTH}} -output.constrain-screen-width "${UI_WIDTH}" - if [[ -n $CI ]] ; then - prefix="โฎ€ " + export UI_WIDTH=55 + readonly UI_WIDTH=55 + output.constrain-screen-width ${UI_WIDTH} + prefix=" โฑ " function test-group() { - echo "${prefix}๐Ÿ“ฆ $*" - hr; echo + output.constrain-screen-width ${UI_WIDTH} + h3bg "$(echo "${prefix}$* " | tr '[:lower:]' '[:upper:]')" } function test-group-ok() { - echo "${prefix}โœ… Tests passed in ${1}" - hr; echo + output.constrain-screen-width ${UI_WIDTH} + arrow.blk-on-grn "Tests passed in ${bakblu}${bldwht}${1} " } function test-group-failed() { - echo "${prefix}โŒ Some tests failed in ${1}" - hr; echo + output.constrain-screen-width ${UI_WIDTH} + arrow.blk-on-red "Some tests failed in ${bakpur}${bldwht}${1} " } else + output.constrain-screen-width ${UI_WIDTH} function test-group() { arrow.blk-on-ylw "$@" @@ -355,7 +357,7 @@ function specs.header() { hr echo printf "\e[48;5;11m\e[48;30;209m ${clr}\n" - printf "\e[48;5;11m\e[48;30;209m BASHMATIC TEST RUNNER, VERSION ${black}$(bashmatic.version) ${clr}\n" + printf "\e[48;5;11m\e[48;31;207m BASHMATIC TEST RUNNER, VERSION ${black}$(bashmatic.version) ${clr}\n" printf "\e[48;5;11m\e[48;30;209m ยฉ 2016-2021 Konstantin Gredeskoul, All Rights Reserved, MIT License. ${clr}\n" printf "\e[48;5;11m\e[48;30;209m ${clr}\n" echo diff --git a/test/path_test.bats b/test/path_test.bats index 4ec7beb..b49b583 100644 --- a/test/path_test.bats +++ b/test/path_test.bats @@ -7,8 +7,17 @@ source lib/array.sh source lib/output.sh source lib/path.sh source lib/is.sh +source lib/file.sh +source lib/time.sh set -e + +@test "path.temp" { + file=$(file.temp) + touch ${file} + [[ -f ${file} ]] +} + @test "path.dirs from STDIN" { local p1="/bin:/Users/kig/bin:/usr/bin:/bin:/sbin" local p2="/bin:a:b:c"