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
#!/usr/bin/env bash | |
# bash: line 3: declare: v: readonly variable | |
for fd in {a..d}; do | |
echo "$fd" | |
bash -x /dev/fd/"${!fd}" | |
done {ofd}<&0 <<\EOFA {a}<&0 <<\EOFB {b}<&0 <<\EOFC {c}<&0 <<\EOFD {d}<&0 <&${ofd} | |
tt() { typeset -r v=; } | |
t() { tt; } |
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
function man { | |
if ! command man -W "$@"; then | |
return 1 | |
elif [[ ! -t 0 ]]; then | |
echo 'STDIN must be a tty.' >&2 | |
return 1 | |
elif [[ $- != *m* ]]; then | |
set -m | |
typeset -f +t "$FUNCNAME" | |
trap 'trap RETURN; set +m' 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
# 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
#!/usr/bin/env bash | |
for sh in ~/doc/programs/bash43 {{b,d}a,po,{m,}k,z}sh bb; do | |
printf '%-8s' "${sh##*/}:" | |
"$sh" </dev/fd/0 | |
done <<\EOF | |
${ZSH_VERSION+:} false && emulate sh | |
set -f -- a b c | |
unset -v IFS | |
printf '<%s> ' ${*}${IFS=}${*}${IFS:=-}"${*}" |
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 | |
${BASH_VERSION+shopt -s extglob lastpipe} | |
function doCompat { | |
if [[ ${!KSH_VERSION} == .sh.version ]]; then | |
builtin pids 2>/dev/null | |
{ | |
eval function BASHPID.get "{ $(</dev/fd/$(($? + 3))) || exit 1; }" | |
} <<-"3" 3<&0- <<-\4 4<&0- |
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
if [[ ${!KSH_VERSION} == .sh.version ]]; then | |
if builtin pids 2>/dev/null; then | |
function BASHPID.get { .sh.value=$(pids -f '%(pid)d'); } | |
elif [[ -r /proc/self/stat ]]; then | |
function BASHPID.get { read -r .sh.value _ </proc/self/stat; } | |
else | |
function BASHPID.get { .sh.value=$(exec sh -c 'echo $PPID'); } | |
fi | |
elif [[ ! ${BASHPID+_} ]]; then | |
echo 'BASHPID requires Bash, ksh93, or mksh >= R41' >&2 |