nash icon indicating copy to clipboard operation
nash copied to clipboard

proposal: Support function invocation when evaluating arguments

Open i4ki opened this issue 9 years ago • 0 comments

fn files(pat, dir) {
        IFS=("\n")
        results <= ls $dir | grep $pat
        return $results
}

λ> mv -v files("png$", ".") ./Images/
'2016-03-10-183202_1802x1080_scrot.png' -> 'Images/2016-03-10-183202_1802x1080_scrot.png'
'2016-07-26-120239_1797x997_scrot.png' -> 'Images/2016-07-26-120239_1797x997_scrot.png'
mv -v files("png$", ".") ./Images/
# must expand to 
mv -v ("2016-03-10-183202_1802x1080_scrot.png" "2016-07-26-120239_1797x997_scrot.png") ./Images
# and then applying list eval
mv "2016-03-10-183202_1802x1080_scrot.png" "2016-07-26-120239_1797x997_scrot.png" ./Images

i4ki avatar Aug 17 '16 13:08 i4ki