diff --git a/.scripts/archive b/.scripts/archive index 0f23824a..a8d09f9e 100755 --- a/.scripts/archive +++ b/.scripts/archive @@ -60,6 +60,13 @@ if [ $# -eq 0 ]; then exit 1 fi +## We need 'realpath' since we need to work on the real path for the input +## files/folders and the archive location. Otherwise we could have troubles with +## circular symlinks and so on. +if ! command -v realpath >/dev/null; then + echo >&2 "'realpath' is required." + exit 1 +fi _archive() { diff --git a/.scripts/asciify b/.scripts/asciify index cc56d762..a3753d8a 100755 --- a/.scripts/asciify +++ b/.scripts/asciify @@ -72,9 +72,7 @@ _asciify() } if [ $# -ge 1 ]; then - for i; do - _asciify "$i" - done + _asciify "$@" else _asciify fi diff --git a/.scripts/cutlines b/.scripts/cutlines index 122932ef..0c0ce803 100755 --- a/.scripts/cutlines +++ b/.scripts/cutlines @@ -44,7 +44,6 @@ done shift $(($OPTIND - 1)) if $OPT_TAIL; then - # sed -n -e ":begin ; 1,${OPT_LINES}!{P;N;D} ; N ; b begin" $1 sed -n -e ":begin ; 1,${OPT_LINES}!{P;N;D} ; N ; b begin" $1 else sed -n -e "1,${OPT_LINES}!p" "$@" diff --git a/.scripts/extract b/.scripts/extract index 85e79ffc..d555421b 100755 --- a/.scripts/extract +++ b/.scripts/extract @@ -60,8 +60,11 @@ command -v atool >/dev/null && echo "You should use atool instead." && echo _extract() { echo "[$1]" - FOLDER="$(realpath "$1")" - FOLDER="${FOLDER%/*}" + case "$1" in + */*) FOLDER="${1%/*}";; + *) FOLDER="." ;; + esac + case "$1" in *.tar*|*.tbz2|*.tbz|*.tgz|*.txz) tar xf "$1" -C "$FOLDER" ;; *.7z) 7z x "$PASS" -o"$FOLDER" "$1";; diff --git a/.scripts/imagemount b/.scripts/imagemount index 9a4a1cb2..bd4b5726 100755 --- a/.scripts/imagemount +++ b/.scripts/imagemount @@ -134,6 +134,13 @@ if [ $# -eq 0 ]; then exit 1 fi +if ! command -v realpath >/dev/null; then + echo >&2 "'realpath' is required." + exit 1 +fi + + +## realpath is needed to check if image was already mounted or not. if $OPT_UNMOUNT; then for i ; do _umount "$(realpath "$i")" diff --git a/.scripts/zshcd b/.scripts/zshcd index 47886d82..51dfbc87 100755 --- a/.scripts/zshcd +++ b/.scripts/zshcd @@ -12,19 +12,21 @@ ZDIRS="$HOME/.cache/zsh/dirs" ## Fetch file location dynamically. if [ ! -f ~/.zshrc ]; then echo '~/.zshrc not found. Exiting.' - exit -fi -if ! command -v realpath; then - echo "'realpath' not found. Exiting." - exit + exit 1 fi +## We need realpath to prevent us from adding duplicates to the zsh +## DIRSTACKFILE. +if ! command -v realpath; then + echo "'realpath' not found. Exiting." + exit 1 +fi SHELL_DIR_GREP="$(grep "SHELL_DIR=" ~/.zshrc | cut -f2 -d=)" [ -n "$SHELL_DIR_GREP" ] && SHELL_DIR="$(eval echo "$SHELL_DIR_GREP")" if [ ! -d "$SHELL_DIR" ]; then echo 'SHELL_DIR not found. Could not search for DIRSTACKFILE. Exiting.' - exit + exit 1 fi ZDIRS_GREP="$(grep -rm1 'DIRSTACKFILE=' "$SHELL_DIR" | cut -f2 -d=)" @@ -32,7 +34,7 @@ ZDIRS_GREP="$(grep -rm1 'DIRSTACKFILE=' "$SHELL_DIR" | cut -f2 -d=)" if [ ! -f "$ZDIRS" ]; then echo 'DIRSTACKFILE not found. Exiting.' - exit + exit 1 fi ## Prepend argument to zsh dirstack. diff --git a/.shell.d/alias_rc b/.shell.d/alias_rc index b38bffa0..3274d0dd 100644 --- a/.shell.d/alias_rc +++ b/.shell.d/alias_rc @@ -45,7 +45,7 @@ alias grep='grep --color=auto' [ ${#XDG_APPS} -ne 0 ] && alias applist='grep -R "^Name=" $XDG_APPS | cut -d'=' -f2 | sort' ## Remove executable attribute. -alias nox='find * -type f -exec chmod a-x {} +' +alias nox='find . -type f -exec chmod a-x {} +' ## Get your external IP. command -v curl >/dev/null && alias myip='curl ifconfig.me'