echo x${output}x
output="${output##*( )}"
echo x${output}x
output="${output%%*( )}"
echo x${output}x
ext="${file##*.}" # string after last '.'
PS4='+ $(date "+%s.%N")\011 ' exec 3>&2 2>$HOME/bashstart.$$.log set -x
set +x exec 2>&3 3>&-
Mac OS X: Darwin refers to the underlying kernel and terminal utilities put together by Apple, which has slightly different (BSD?) implementations than Arch Linux (GNU?). Shell scripts are called OSX when they refer more to the OS X userspace.
Perhaps write a scriptc that searches for "base" upgrades, and runs that first, then runs upgrade again.
echo '# Ignore everything in this directory *
!.gitignore ' >> EMPTY_DIRECTORY/.gitignore
touch EMPTY_DIRECTORY/.gitignore
#alias cd 'cd !*; ls' # This is how to include args in an alias
buzz() { echo "buzz" }
escape() {
printf "\\x%s"
data_url() {
local mimeType=$(file -b --mime-type "$1")
if test
Scripts should be 'sourced' into the shell, because they use shell language. trying to run a script as an executable is just a layer of obfuscation in a subprocess.
The difference between a shell function and a script is that a shell function is an atomic action typed by hand and returned to the terminal immediately. A script takes more time or is usually executed as/by another process. A shell function should be merely a modified way to start another program. A script is defined by the programming logic it is written in, and is a program in itself.
IFS="$(printf '\n\t')"
IFS="&"
#set --
test -z "$location" && location=/ || printf -v location '%b' "${location//%/\x}"
A shell's functions are to assist in executing files, managing files, managing processes, and serving files+pipes to processes, to aid in browsing/displaying/editing.
It excells at doing this locally and remotely because it is a text interface, but smart command+file completion, suggestion, and highlighting is paramount.
Currently I use '&>/dev/null' and '>file' without a space in the name. The shortcuts '&2' and '&1' are not very clear, but are sometimes unavoidable.
Only export variables that might be used by other programs. Do not export variables specific to the functionality of the shell
Shell script naming priority should try to be as specific as possible (shell name whenever possible). Scripts are sourced in this order:
Does it work only in your SHELL? or is it important for any tty or shell (SH)? Does it work only on your distro (ID)? or is it important for any of the same kernel (OS)? SHELL (program) > SH (any shell) > ID (distro) > OS (kernel) example: .bash > .sh > .arch > .linux
if connected; then true fi
test ! connected && echo "Error: No internet connectivity." >/dev/stderr && return 1
test $EUID = 0 || return
test $EUID != 0 && echo "Error: You must be root to do this." >/dev/stderr && return 1
(if) true && (then) || (if) false && || (else)
true && || false && ||
true: && false: ||
unset ANSWER echo -n "Do this thing? [y/N] " read ANSWER ANSWER=$(echo "$ANSWER" | tr '[:upper:]' '[:lower:]') if test "$ANSWER" = "y" || test "$ANSWER" = "yes"; then true fi
unset ANSWER echo -n "Do you agree with this? [yes or no]: " read ANSWER case $ANSWER in [yY] | [yY][Ee][Ss] ) true ;;
[nN] | [n|N][O|o] ) false ;; *) echo "Error: Invalid input" >/dev/stderr esac
tmp=${TMPDIR:-/tmp}
tmp=${tmp}/tempdir.$$
$(umask 077 && mkdir