ytet5uy4 / fzf-widgets

ZLE widgets of fzf
MIT License
87 stars 18 forks source link

`private` replaced to `local` for support zsh < 5.3 #15

Closed popstas closed 7 years ago

popstas commented 7 years ago

Tested widgets:

private vars scoped current function. local vars scoped current function and inner functions.

Demo:

#!/bin/zsh

test_private() {
    private pb="func"
    test_private_inner
}

test_private_inner() {
    echo "private_inner: pb = $pb"
    private pb="func_inner"
}

echo "pa = $pa"
echo "pb = $pb"
test_private

###

test_local() {
    local lb="func"
    test_local_inner
}

test_local_inner() {
    echo "local_inner: lb = $lb"
    local lb="func_inner"
}

echo "la = $la"
echo "lb = $lb"
test_local

Output:

pa = 
pb = 
private_inner: pb = 
la = 
lb = 
local_inner: lb = func

After replace private to local all tested widgets begin works on zsh 5.1.1 (Ubuntu 16.04). On older systems (zsh 5.0.2 on Ubuntu 14.04, zsh 4.3.10 on Debian 6) startup errors leaved, but widgets don't inserted results.

On zsh <= 5.0.2 was:

selector-insert:3: unknown file attribute

Fixed by extract variable definition to separate line.

Now all tested widgets except fzf-git-checkout (see #14) works for zsh 5.0.2 and most widgets works for 4.3.10.

ytet5uy4 commented 7 years ago

LGTM :+1: Thanks!