Skip to content

Instantly share code, notes, and snippets.

View hypersoft's full-sized avatar

Triston J. Taylor hypersoft

View GitHub Profile
@hypersoft
hypersoft / lib.file.slurp.each
Created February 14, 2013 16:58
Slurp each file to a var (with optional append) or standard output.
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; };
@hypersoft
hypersoft / lib.input.file.forEach
Last active December 13, 2015 18:18
Automatic I/O loop executive with environment sanitation, predefined macro source expansion, and optional script output to file, for consecutive cached calls / common operations / examination. The generated script, or executed function takes multiple files, or stdin as its arguments.
lib.input.file.forEach ()
{
# BOOT STRAPS
[[ "$1$2$3" == --buildprintfxchar ]] && {
echo "builtin printf -- '\\x`builtin printf '%02X' "'${4}"`';";
return;
}
@hypersoft
hypersoft / printfx.sh
Last active August 25, 2017 18:58
Extended printf (printfx)
#
# 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: