JacobEvelyn / git-self-blame

Stop trying to always blame others and take some responsibility already.
MIT License
169 stars 5 forks source link

Compatibility with other shells #3

Open jirutka opened 6 years ago

jirutka commented 6 years ago

Definitely works in Bash and Zsh. Probably works in most other shells?

No, it does not work in any other shells; due to:

git-self-blame:90:

paste -d ' ' <(for _ in $(seq 1 "$(wc -l < "$intermediate_tmpfile")"); do echo "$myself"; done) "$intermediate_tmpfile" > "$mailmap_tmpfile"

<(…) (Process Substitution) is so-called bashism – it’s not specified by POSIX Shell Command Language and (as I know) the only shells that implements it is Bash and ZSH. ash, dash, ksh, … or any other POSIX-compatible shell does not implement this syntax.

This is the only problematic part, the rest of the script is POSIX-sh compliant.

JacobEvelyn commented 6 years ago

Thanks, @jirutka! I confess I'm relatively new to shell scripting and don't completely understand how the POSIX standard interacts with what different shells actually support. It looks like you're right that not every shell supports process substitution although I don't totally trust that Wikipedia feature table since on my Mac all of the shells that come installed (bash, zsh, ksh, and tcsh... /bin/sh is a clone of /bin/bash and /bin/csh is a clone of /bin/tcsh) seem to support this.

I'm happy to change this though (or accept a PR to change it if you want to take a crack at it). Am I correct that the best way to change this would be to use a temp file (basically alternative #1 in Wikipedia since the named pipe approach would require a scheme to generate random names for pipes so that two of these processes can be run concurrently? Or is there a better/easier approach?