Closed MrJoy closed 2 years ago
Are there any considerations here re: Windows / WSL we need to account for if we use grep + wc?
That's an excellent question. I've got an engineer who's using WSL that I can ask. I will update the ticket when I have an answer.
Another option might be something like:
if ! type rbenv &> /dev/null
then
if ! command -v foreman &> /dev/null
then
# ...
fi
else
if ! foreman version >/dev/null
then
# ...
fi
fi
It's a little more cumbersome to be sure, but it seems like it would be viable. I think it would neatly compartmentalize any potential quirks / changes of semantics to just us rbenv
users.
I'm informed by my colleague that when run from a Linux terminal in WSL, grep
works fine.
@dhh What can I do to move this forward?
Could if ! foreman version &> /dev/null
be used across the board regardless if the developer is using rbenv or not?
@t27duck That solution is compatible with rbenv
, and certainly seems lower risk. Honestly, I feel silly that it didn't occur to me. Might be worth tossing in a (Edit: Sorry, my shell-fu is weak. Didn't notice the use of > /dev/null 2>&1
to avoid cluttering output, since you'll get some output to STDOUT/STDERR regardless of which environment you're on.&>
instead of >
.)
Sounds like @t27duck's solution would do. Feel free to PR that.
Done.
Because rbenv uses shims, this line in the generated
bin/dev
script will always return true in an environment in whichforeman
has been installed in any gemset at any point, even if it's not in the current gemset:I've found this to be a viable alternative that I believe should work everywhere:
(The use of
grep
is because when foreman isn't installed,gem list
will produce an empty line of output.)