diff --git a/local/bin/x-mkd b/local/bin/x-mkd deleted file mode 100755 index 7daa2f8..0000000 --- a/local/bin/x-mkd +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -# -# Create a directory and cd into it -# Usage: x-mkd - -set -euo pipefail - -# Set verbosity with VERBOSE=1 -VERBOSE="${VERBOSE:-0}" - -# Function to print usage information -usage() -{ - echo "Usage: $0 " - exit 1 -} - -# Function to print messages if VERBOSE is enabled -# $1 - message (string) -msg() -{ - [[ "$VERBOSE" -eq 1 ]] && echo "$1" -} - -# Function to create a directory and cd into it -# $1 - directory to create and cd into (string) -mkcd() -{ - local dir=$1 - - mkdir -p "$dir" && msg "Directory $dir created" - - cd "$dir" || { - msg "Failed to cd into $dir" - exit 1 - } - msg "Changed directory to $dir" -} - -# Main function -main() -{ - if [ "$#" -ne 1 ]; then - usage - fi - - mkcd "$1" -} - -main "$@" diff --git a/local/bin/x-mkd.md b/local/bin/x-mkd.md deleted file mode 100644 index 4b5aabe..0000000 --- a/local/bin/x-mkd.md +++ /dev/null @@ -1,19 +0,0 @@ -# x-mkd - -Create a directory and immediately `cd` into it. - -## Usage - -```bash -x-mkd -``` - -Set `VERBOSE=1` for status messages. - -## Example - -```bash -x-mkd project && git init -``` - - diff --git a/local/bin/x-validate-sha256sum.sh b/local/bin/x-validate-sha256sum.sh deleted file mode 100755 index 3f832b9..0000000 --- a/local/bin/x-validate-sha256sum.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash -# -# This script contains a helper for sha256 validating your downloads -# -# Source: https://gist.github.com/onnimonni/b49779ebc96216771a6be3de46449fa1 -# Author: Onni Hakala -# License: MIT -# -# Updated by Ismo Vuorinen 2022 -## - -set -euo pipefail - -# Stop program and give error message -# $1 - error message (string) -error() -{ - echo "(!) ERROR: $1" >&2 - exit 1 -} - -# Check for sha256sum command -if ! command -v sha256sum &> /dev/null; then - error "sha256sum could not be found, please install it first" -fi - -# Return sha256sum for file -# $1 - filename (string) -get_sha256sum() -{ - sha256sum "$1" | head -c 64 -} - -# Validate input arguments -validate_inputs() -{ - if [ -z "${filename:-}" ]; then - error "You need to provide filename as the first parameter" - fi - - if [ -z "${file_hash:-}" ]; then - error "You need to provide sha256sum as the second parameter" - fi -} - -# Main validation logic -validate_file() -{ - if [ ! -f "$filename" ]; then - error "File $filename doesn't exist" - elif [ "$(get_sha256sum "$filename")" = "$file_hash" ]; then - echo "(*) Success: $filename matches provided sha256sum" - else - error "$filename doesn't match provided sha256sum" - fi -} - -# Main function -main() -{ - filename=$1 - file_hash=$2 - - validate_inputs - validate_file -} - -main "$@" diff --git a/local/bin/x-validate-sha256sum.sh.md b/local/bin/x-validate-sha256sum.sh.md deleted file mode 100644 index 0432160..0000000 --- a/local/bin/x-validate-sha256sum.sh.md +++ /dev/null @@ -1,14 +0,0 @@ -# x-validate-sha256sum.sh - -This script contains a helper for sha256 validating your downloads - -## Usage - -```bash -x-validate-sha256sum.sh file sha256sum -``` - -The script computes the SHA256 hash of `file` and compares it to the -expected value. It exits non-zero if the sums differ. - - diff --git a/tests/x-mkd.bats b/tests/x-mkd.bats deleted file mode 100755 index 06985e3..0000000 --- a/tests/x-mkd.bats +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bats - -@test "x-mkd creates directory" { - dir="$BATS_TMPDIR/mkd-test" - run env VERBOSE=1 bash local/bin/x-mkd "$dir" - [ "$status" -eq 0 ] - [ -d "$dir" ] -} - -@test "x-mkd with no args shows usage" { - run bash local/bin/x-mkd - [ "$status" -eq 1 ] - [[ "$output" == "Usage:"* ]] -}