Skip to content

Instantly share code, notes, and snippets.

@d630
Last active June 17, 2016 13:34
Show Gist options
  • Save d630/69a65e8ef50f84912e574ea9a2be0400 to your computer and use it in GitHub Desktop.
Save d630/69a65e8ef50f84912e574ea9a2be0400 to your computer and use it in GitHub Desktop.
zsh: nested function definition with reserved word "function" and arithmetic compound as body
fn () {
function fn ((1))
function fn ((1)) 2>/dev/null
}
functions fn
@d630
Copy link
Author

d630 commented Jun 17, 2016

In zsh 5.2 (x86_64-debian-linux-gnu) I get:

fn () {
    fn ((1)) () {
        fn ((1)) () {
             2> /dev/null
        }
    }
}

@d630
Copy link
Author

d630 commented Jun 17, 2016

Use instead function fn ():

fn () { 
        function fn () ((1))
        function fn () ((1)) 2>/dev/null
}

functions fn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment