Snaipe / dot-git

Managing your dotfiles the Git Way™
44 stars 26 forks source link

git-profile compatibility with osx #3

Open ealprr opened 6 years ago

ealprr commented 6 years ago

On osx, dot-profile seems broken:

$ dot profile add test
/Users/ealprr/.config/dotgit/bin/git-profile: line 38: local: `$arg;;
            -*) >&2 echo dot:': not a valid identifier
/Users/ealprr/.config/dotgit/bin/git-profile: line 38: local: `$arg.; exit 3;;
            *) plain=': not a valid identifier
/Users/ealprr/.config/dotgit/bin/git-profile: line 38: local: `$arg;;
        esac;
        i=1;
    done;
    while ': not a valid identifier
/Users/ealprr/.config/dotgit/bin/git-profile: line 38: local: `$arg;
        i=1;
    done;
    eval set': not a valid identifier
/Users/ealprr/.config/dotgit/bin/git-profile: line 38: local: `
    EOF
    )': not a valid identifier
Snaipe commented 6 years ago

Interesting. This should be standard POSIX shell scripting, so I'm not sure what changes on OS X's /bin/sh.

I don't have an OS X machine handy right now, does their /bin/sh support local in shell functions?

Snaipe commented 6 years ago

Oh, I stand corrected: local was proposed for POSIX, but isn't currently part of the standard, so I would wager that this is the problem.

ealprr commented 6 years ago

Honestly, I do not understand what is wrong here. local is available within bsd sh:

% sh
sh-3.2$ local i
sh: local: can only be used in a function
sh-3.2$ function test() { local i=0; i=$(($i+1)); echo "$i"; }
sh-3.2$ test
1