Enable shell alias expansion
I'm not actually sure if this is a good idea, but it works for my purposes.
I say it's optimistic, because I didn't know what flags other shells were looking for, and I was hoping -O would be a consistent flag for shell options or that shell options would be the same across shells. That's not true for zsh, which uses -o http://linux.die.net/man/1/zsh
I'm opening the pull request to start a discussion. If it seems useful, I can see about getting this working with other shells.
Thanks for a gr-eat tool. :)
@mixu If this seems like something that could be useful, I'd be happy to detect other shells and set options appropriately. What do you think?
Sorry for the long delay on this! I wasn't sure what the impact of this would be on people who use other shells and then didn't have time to test it properly. I think if it works in bash, zsh and maybe a third shell like fish or dash (don't really know since I haven't seen any stats on how popular different shells are??), it's probably good enough.
Rather than enabling this by default, it might be best to look at what process.env.SHELL contains and then only adding the extra flags when we know that that shell supports them. In any case thanks for the patch, I'll cherrypick 8926c950216e9bda14a16fda49f020f9288f0757 and clean it up a bit.
closing; cherry-picked the commit
Actually, after some testing I'm unable to get this to work at all on OSX - could you specify which environment this did work in? Just running the patch in master gets me this:
[gr @master] ./bin/gr gs
in ~/mnt/iv
/bin/bash: gs: command not found
spawn-task: "gs" exited with nonzero exit code: 127
[gr @master] zsh --version
zsh --version
zsh 5.0.7 (x86_64-apple-darwin14.0.0)
[gr @master] bash --version
bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.
The closest I got to this working was writing out actual shell scripts in the form:
#!/bin/bash
shopt -s expand_aliases
gs
(ran with bash -i test.sh) and
#!/bin/zsh
source ~/.zshrc
setopt aliases
gs
ran with zsh test.sh.
hmm, looks like https://github.com/jdfreder/pur/blob/master/src/dealias.js does it by running a command to sync up the aliases and then does the actual alias replacing via regexp - that might work.
e.g. zsh -i -c 'alias' / bash -l -c 'alias -p' (OSX) / bash -i -c 'alias -p' (Linux). It's a bit hacky but could work.
I didn't see your messages until now! The fork is still working for me on OSX (on a different machine, no less). I'll look into what might be going on.