*{atclone,atdelete}-handler,plugin.zsh: Automatic-empty sbin ice

This commit is contained in:
Sebastian Gniazdowski 2019-11-09 08:33:30 +01:00
parent 5364435924
commit b8fea5cc7a
3 changed files with 45 additions and 7 deletions

View file

@ -77,16 +77,35 @@ if [[ -n "${ZPLG_ICE[node]}" ]] {
# sbin'' ice creation of shims (the name borrowed from rbenv)
#
if [[ -n "${ZPLG_ICE[sbin]}" ]] {
if (( ${+ZPLG_ICE[sbin]} )) {
local -a sbins srcdst
sbins=( "${(s.;.)ZPLG_ICE[sbin]}" )
sbins=( ${(s.;.)ZPLG_ICE[sbin]} )
local sbin
for sbin ( $sbins ) {
for sbin ( $sbins "" ) {
integer set_gem_home=0 set_node_path=0 set_cwd=0 \
use_all_null=0 use_err_null=0 use_out_null=0
if [[ -z $sbin && ${#sbins} -eq 0 ]]; then
if [[ -f $dir/${id_as:t} ]]; then
sbin="$dir/${id_as:t}"
elif [[ -n $plugin && -f $dir/$plugin ]]; then
sbin="$dir/$plugin"
elif [[ -n $url && -f $dir/${url:t} ]]; then
sbin="$dir/${url:t}"
else
local -a files
files=( $dir/*(*Non:t) )
if (( ${#files} )); then
sbin="${files[1]}"
else
print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
break
fi
fi
fi
srcdst=( ${(@s.->.)sbin} )
srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
[[ ${srcdst[1]} = [gncNEO]#g[gncNEO]#:* ]] && set_gem_home=1

View file

@ -14,14 +14,33 @@ local nl=$'\n'
# sbin'' ice creation of shims (the name borrowed from rbenv)
#
if [[ -n "${ZPLG_ICE[sbin]}" ]] {
if (( ${+ZPLG_ICE[sbin]} )) {
local -a sbins srcdst
sbins=( "${(s.;.)ZPLG_ICE[sbin]}" )
sbins=( ${(s.;.)ZPLG_ICE[sbin]} )
local sbin
integer set_gem_home set_node_path
for sbin ( $sbins ) {
for sbin ( $sbins "" ) {
if [[ -z $sbin && ${#sbins} -eq 0 ]]; then
if [[ -f $dir/${id_as:t} ]]; then
sbin="$dir/${id_as:t}"
elif [[ -n $plugin && -f $dir/$plugin ]]; then
sbin="$dir/$plugin"
elif [[ -n $url && -f $dir/${url:t} ]]; then
sbin="$dir/${url:t}"
else
local -a files
files=( $dir/*(*Non:t) )
if (( ${#files} )); then
sbin="${files[1]}"
else
print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
break
fi
fi
fi
srcdst=( ${(@s.->.)sbin} )
srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
[[ ${srcdst[1]} = (g|ng|gn):* ]] && set_gem_home=1 || set_gem_home=0

View file

@ -20,7 +20,7 @@ autoload .za-bgn-bin-or-src-function-body \
hook:\!atload \
:za-bgn-atload-handler \
:za-bgn-help-handler \
"fbin''|sbin''|gem''|node''|fmod''|fsrc''|ferc''" # also register new ices
"fbin''|sbin|gem''|node''|fmod''|fsrc''|ferc''" # also register new ices
@zplg-register-annex "z-a-bin-gem-node" \
hook:atclone \