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 dirname { | |
local names=() delim='\n' n x | |
local VERSION=0.1 | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
-h|--help) | |
echo "Usage: dirname [OPTIONS] [--] NAME ... | |
Removes the last non-slash component from NAME and the slashes that |
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 extglob | |
[[ BASH_VERSINFO -ge 5 ]] && set -u | |
#### Implementation Snippet Begins #### | |
function mapfile.error { | |
printf '%s\n' "$1" "$@" | |
exit "${2-1}" | |
} |
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
diff --git a/src/utils_password.c b/src/utils_password.c | |
index 58f3a7b..5a055a8 100644 | |
--- a/src/utils_password.c | |
+++ b/src/utils_password.c | |
@@ -106,33 +106,60 @@ static int tools_check_password(const char *password) | |
/* Password reading helpers */ | |
-static ssize_t read_tty_eol(int fd, char *pass, size_t maxlen) | |
+static ssize_t read_tty_eol(int fd, int ofd, char *pass, size_t maxlen) |
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 compare_versions { | |
local a=${1%%.*} b=${2%%.*} | |
[[ "10#${a:-0}" -gt "10#${b:-0}" ]] && return 1 | |
[[ "10#${a:-0}" -lt "10#${b:-0}" ]] && return 2 | |
a=${1:${#a} + 1} b=${2:${#b} + 1} | |
[[ -z $a && -z $b ]] || compare_versions "$a" "$b" | |
} |
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 get_opt_and_optarg { | |
local optional=false | |
if [[ $1 == @optional ]]; then | |
optional=true | |
shift | |
fi |
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 extglob | |
function grep.fail { | |
printf '%s\n' "$1" >&2 | |
exit "${2-1}" | |
} | |
function grep.get_opt_and_optarg { | |
OPT=$1 OPTARG= OPTSHIFT=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
#!/usr/bin/env ruby | |
require 'find' | |
Find.find('.') | |
.inject({}) do |hash, path| | |
base = path.gsub(/.*\//, '') | |
(hash[base] ||= []) << path unless base.empty? | |
hash | |
end |
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 | |
# Based on https://askubuntu.com/a/571711/415750 | |
function main { | |
local screen_width screen_height WIDTH HEIGHT new_pos_x new_pos_y | |
read screen_width screen_height < <(xdotool getactivewindow getdisplaygeometry) | |
eval "$(xdotool getactivewindow getwindowgeometry --shell | grep -e WIDTH= -e HEIGHT=)" | |
new_pos_x=$(( screen_width / 2 - WIDTH / 2 )) | |
new_pos_y=$(( screen_height / 2 - HEIGHT / 2 )) |
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 | |
# ---------------------------------------------------------------------- | |
# sudodir | |
# | |
# Executes command as owner of current directory. | |
# | |
# It also calls xhost to give owner access to X if user allows it. | |
# |
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
diff --git a/libs/core.bash.in b/libs/core.bash.in | |
index 2800cc5..a3791ba 100644 | |
--- a/libs/core.bash.in | |
+++ b/libs/core.bash.in | |
@@ -113,6 +113,9 @@ do_action() { | |
|| die -q "Action ${subaction} unknown" | |
check_do "do_${subaction}" "$@" | |
fi | |
+ if [[ $? -eq 0 && -e /etc/eselect/hooks/${ESELECT_MODULE_NAME}/${subaction} ]]; then | |
+ source "/etc/eselect/hooks/${ESELECT_MODULE_NAME}/${subaction}" |
OlderNewer