square / spacecommander

Commit fully-formatted Objective-C as a team without even trying.
Other
1.13k stars 177 forks source link

Support fish shell compatible commit commands #21

Closed orta closed 9 years ago

orta commented 9 years ago

Hey there, I'm not amazing on my bash skills, so please double check me, but this should be checking for the existence of the $FISH_VERSION env var, and then offering different instructions.

alanf commented 9 years ago

Hi @orta, can you give a little more background? One thing I'm not sure about is, how do the rest of these scripts work in fish if && is not valid fish shell syntax?

orta commented 9 years ago

So I think the script is being ran fine in fish because it is using bash to run the script, or maybe a compatibility mode in the shell. However in user-land running something with && is a failure:

~/d/i/a/eigen (cleanup_auction) ⏛  echo "hi" && echo "ok"
Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.
fish: echo "hi" && echo "ok"
                 ^

Though if it's being ran in bash, I wonder if it gets access to the host ENV vars, hrm, I might need to take a second look over this PR.

alanf commented 9 years ago

@orta what about just prefixing the command with bash so fish and other shells can interpret it using bash syntax?

orta commented 9 years ago

That, @alanf, sounds like the smartest and simplest idea - here's a star :star2:

orta commented 9 years ago

Hrm, that won't work as it's for the user to run, though it did put me on a "what if the syntax would do both?" quest. The conclusion of this was echo "hi"; echo "world" which works in both, but doesn't support chain failing. E.g. the first one dies then the second command doesn't get run.

alanf commented 9 years ago

Another idea is, there are instructions for a single script that can run and fix all the issues without needing to copy-paste multiple lines and are output at the end:

https://github.com/square/spacecommander/blob/master/format-objc-hook#L34

the script is ./format-objc-files.sh -s

maybe I should highlight this at the beginning

orta commented 9 years ago

I've always figured that would run it against all files, and thus be super slow, if it was just against the changed files I'd use that all the time instead.

alanf commented 9 years ago

@orta there's a different script for that, format-objc-files-in-repo.sh. I'll update the output to clarify

orta commented 9 years ago

:+1: