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 | |
# ormaaj's init | |
\unalias -a | |
shopt -s lastpipe extglob expand_aliases | |
shopt -u assoc_expand_once | |
typeset -ga bool=([1]=) | |
function initializeBuiltins { | |
typeset -a a |
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 | |
typeset -gx BASH_COMPAT=51 | |
shopt -u assoc_expand_once | |
function assignArray { | |
typeset -n ref=$1 || return | |
shift | |
[[ ${ref@a} == *A* && "! ($# % 2)" -ne 0 ]] || return | |
typeset -A map |
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 initializeBuiltins { | |
local - | |
typeset -a a | |
typeset x y z | |
set +m | |
typeset libdir=${fsRoot%%+(/)}/usr/lib64 | |
[[ -d ${libdir}/bash ]] || libdir=${rootPath%%+(/)}/lib64 | |
for x in "${libdir}"/{ctypes.so,bash/!(hello|truefalse|mypid|necho|*.*)}; do | |
if [[ $(file -b --mime-type -- "$x") == 'application/x-sharedlib' && !$? -ne 0 ]]; 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
shopt -s lastpipe extglob globstar | |
shopt -u assoc_expand_once | |
function initializeBuiltins { | |
typeset -a a | |
typeset x y z | |
set +m | |
typeset libdir=${fsRoot%%+(/)}/usr/lib64 | |
[[ -d ${libdir}/bash ]] || libdir=${rootPath%%+(/)}/lib64 |
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
(ins)root@ormaaj-laptop (3852812) /home/ormaaj # PATH=$(readlink -sne ~ormaaj/doc/programs/portage/bin):${PATH##+(:)} PYTHONPATH=$(readlink -sne ~ormaaj/doc/programs/portage/lib):${PYTHONPATH##+(:)} NOLTO= NOGRAPHITE= NOGRAPHITE2= emerge -j 1 -bav dev-lang/python | |
These are the packages that would be merged, in order: | |
Calculating dependencies... done! | |
[ebuild R ] dev-lang/python [3.11.0_beta4-r2:3.11::gentoo] USE="bluetooth examples gdbm ncurses readline sqlite ssl -build -hardened -libedit -lto -pgo -test -tk -verify-sig -wininst" 0 KiB | |
Total: 1 package (1 reinstall), Size of downloads: 0 KiB | |
Would you like to merge these packages? [Yes/No] |
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 python3 | |
import subprocess, itertools | |
class Shell(list): | |
def __init__(self, shell, cmds): | |
self.shell = shell | |
super().__init__([(x, self.__run(x)) for x in cmds]) | |
def __iter__(self): |
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 setupGpgAgent { | |
# gpg-agent uses .gnupg but will not create the directory itself for new users. | |
if ! { [[ -d ~/.gnupg ]] || mkdir -p -- ~/.gnupg; }; then | |
printf 'bashrc: %s\n' 'No ~/.gnupg directory exists and failed to create it.' >&2 | |
return 0 | |
fi | |
if [[ -t 0 ]] && { GPG_TTY=$(readlink -sne /dev/fd/0) || GPG_TTY=$(tty); }; then | |
export GPG_TTY | |
else |
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 setupDirColors { | |
if [[ ${FUNCNAME[0]} == "${FUNCNAME[1]}" ]]; then | |
typeset -n LS_COLORS=$1 | |
typeset dirc | |
if dirc=$("$(type -P dircolors 2>/dev/null)" -b); then | |
alias export=:; eval "$dirc"; unalias export | |
fi | |
else | |
typeset colors ret | |
if ! shopt -q expand_aliases; 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
To hopefully add some insight, here's briefly my understanding of how | |
namerefs are supposed to work in these cases given the 3 implementations | |
I'm aware of. | |
Between ksh93, bash, and mksh, there are 3 different types of namerefs. | |
All three support "dynamic" namerefs, where each time a variable is | |
referenced, the shell looks at the currently visible variable whose name | |
is pointed to by the reference. All namerefs in bash and mksh are of | |
this type. |
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 | |
if [[ ${KSH_VERSION+${!KSH_VERSION}} == .sh.version ]]; then | |
typeset -n FUNCNAME=.sh.fun | |
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 |