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
#!/usr/bin/env bash | |
unset -v x y sh | |
while IFS= read -r s; do | |
IFS= declare -a "shells=( $s )" | |
IFS= read -r testCase | |
printf '%s\n%6s%s\n' "$testCase" '' 'x y x y' | |
for sh in "${shells[@]}"; do | |
printf '%-4s: %s\n' "$sh" "$("$sh" -c "$testCase")" |
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
#!/usr/bin/env ksh | |
# Charles Cooke's 16-color Mandelbrot | |
# http://earth.gkhs.net/ccooke/shell.html | |
# Combined Bash/ksh93 flavors by Dan Douglas (ormaaj) | |
function doBash { | |
typeset P Q X Y a b c i v x y | |
for ((P=10**8,Q=P/100,X=320*Q/cols,Y=210*Q/lines,y=-105*Q,v=-220*Q,x=v;y<105*Q;x=v,y+=Y)); do | |
for ((;x<P;a=b=i=c=0,x+=X)); do |
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
# Print or assign a random alphanumeric string of a given length. | |
# rndstr len [ var ] | |
function rndstr { | |
if [[ $FUNCNAME == "${FUNCNAME[1]}" ]]; then | |
unset -v a l | |
printf "$@" | |
elif [[ $1 != +([[:digit:]]) ]]; then | |
return 1 | |
elif (( ! $1 )); then | |
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
function mtimes { | |
typeset x= | |
typeset -i n=0 | |
for x; do | |
n=0 | |
if [[ -d $x ]]; then | |
mtimes "$x"/* | |
else | |
while [[ ${arr[n]+$x} -ot ${arr[n]} ]]; do | |
((n++)) |
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
# Copyright 1999-2012 Gentoo Foundation | |
# Distributed under the terms of the GNU General Public License v2 | |
# $Header: $ | |
EAPI=4 | |
# Specify an alternate AST distribution if needed. | |
myPkgName= | |
# This section allows for the possibility to build from git sources, |
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
# /etc/bash/bashrc | |
# | |
# This file is sourced by all *interactive* bash shells on startup, | |
# including some apparently interactive shells such as scp and rcp | |
# that can't tolerate any output. So make sure this doesn't display | |
# anything or bad things will happen ! | |
[[ $- == *i* ]] || return | |
shopt -s checkwinsize histappend extglob lastpipe globstar cmdhist lithist |
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
# Find the last modified file selected from a glob. | |
# Usage: latest <glob> <varname> | |
# Takes an optional glob and optional varname. | |
# glob defaults to '*'. If varname is set, assign to varname, | |
# else output to stdout. | |
function latest { | |
if [[ $FUNCNAME == "${FUNCNAME[1]}" ]]; then | |
unset -v x latest files | |
printf -v "$@" | |
elif (($# > 2)); then |
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 | |
# GNU stat(1) required! | |
typeset -a filesystems | |
disk_space_threshold=85 | |
hsummary= | |
filesystems=(/ /DB-Backup) | |
function checkFS { |
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
# Adjacent function depth. | |
# Search up the stack for the first non-FUNCNAME[1] and count how deep we are. | |
# Result goes to stdout, or is optionally assigned to the given variable name. | |
function callDepth { | |
if [[ $FUNCNAME == "${FUNCNAME[1]}" ]]; then | |
unset -v n | |
printf "$@" | |
else | |
# If callee is empty then we're definitely being called from global scope. | |
# If there is exactly one callee named main, and len(BASH_SOURCE) == 2, then this is also definitely global scope. |
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 | |
shopt -s expand_aliases extglob | |
alias \[='x=${BASH_COMMAND#"${BASH_ALIASES[\[]} "} command eval eval \"[[ \$x]\" \#' | |
set -x | |
[ ormaaj == or+([ma])j ] | |
echo "$?" |