This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This file is a part of Hypersoft bash-masters | |
# | |
# Copyright (C) 2013, Triston J. Taylor ([email protected]) | |
# | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are | |
# met: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib.input.file.forEach () | |
{ | |
# BOOT STRAPS | |
[[ "$1$2$3" == --buildprintfxchar ]] && { | |
echo "builtin printf -- '\\x`builtin printf '%02X' "'${4}"`';"; | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib.file.slurp.each () | |
{ | |
# slurp each file to optional var or output with optional append to var | |
declare data="REPLY" record='' file=''; | |
declare -i echo=1 append=0; | |
while [[ ${1:0:1} == - ]]; do | |
[[ $1 == -- ]] && { shift; break; }; | |
[[ $1 == -a ]] && { append=1; shift; continue; }; | |
[[ $1 =~ ^(-v|--var)$ ]] && { data=$2; shift 2; continue; }; | |
[[ $1 =~ ^(-n|--no-echo)$ ]] && { shift; echo=0; continue; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib.read.for () | |
{ | |
# Usage: lib.read.for [line|char|record delimiter "char"] [do command] [in file ...] | |
declare -A env[line]=0 env[delimited]=0 env[binary]=0; declare -i EOF; | |
if [[ "$1" == char ]]; then env[binary]=1; shift; | |
elif [[ "$1" == line ]]; then env[line]=1; shift; | |
elif [[ "$1$2" == recorddelimiter ]]; then env[delimited]=1 env[delimiter]="$3"; | |
shift 2; shift; fi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib.array.count () | |
{ | |
eval echo \${#$1[@]}; | |
} | |
lib.array.dump () | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse.nested.block() # char start, char end[, buffer] | |
{ declare \ | |
_Usage=" | |
USAGE: $FUNCNAME [-u|-h|--help|-c|--chained] START END [BUFFER] | |
" \ | |
_Help=" | |
My name is \`$FUNCNAME' I was constructed by Triston J. Taylor (pc.wiz.tt) | |
as a generic method to parse nested blocks at my standard input on the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file.cache.sh; | |
# selective broadcast | |
file.cache.stream() { # heading alias | |
eval printf %s \"\${$2[@]:$1}\"; | |
} | |
# selective width broadcast | |
file.cache.stream.block () { # heading distance alias | |
eval printf %s \"\${$3[@]:$1:$2}\"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
hash sed fold || { | |
printf "%s\n" "bin2inc: error: missing program dependencies"; | |
exit 1; # if you don't have sed or fold, get them. | |
} >&2; | |
[[ -n $2 ]] && { | |
[[ -f "$2" && -r "$2" ]] || { | |
printf "%s\n" "bin2inc: error: argument 2 is not a valid file: $2"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -i MAJOR="0" | |
declare -i MINOR="0" | |
declare -i MINORMAX="99" | |
declare -i REVISION="0" | |
declare -i REVISIONMAX="9999" | |
buildnum () | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
pipe=cat; | |
ifilter=./ifilter; [ -e "$ifilter" ] || ifilter=ifilter; | |
if [ "${1:0:1}" == '-' ]; then | |
pipe="$ifilter $1"; | |
shift; | |
fi; |
OlderNewer